The official Docker image for the Twilio CLI enables you to use the CLI in a portable and secure container-based environment without having to manage the installation yourself.
To run the Twilio CLI Docker image with an interactive bash shell, use:
_10docker run -it --rm twilio/twilio-cli bash
Once the container has finished downloading, and you have entered the shell, you can issue commands using the CLI. For example:
_10$ docker run -it --rm twilio/twilio-cli bash_10_10root@1234:/twilio# twilio profiles:list_10ID Account SID Active_10you ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX true_10main ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX false
It is also possible to pass commands directly to the Docker image for single, contained operations. For example, you can check the running version of the Twilio CLI with the following:
_10$ docker run -it --rm twilio/twilio-cli twilio --version_10twilio-cli/3.0.0 linux-x64 node-v14.18.1
Since the container is cleaned up between each execution, it is useful to pass credentials and configuration directly to the Docker container instead of needing to use
twilio login on each run.
If you have your profile credentials set as environment variables, you can pass them directly to the Docker container. The environment variables will be picked up by the containerized version of the Twilio CLI:
_11$ export TWILIO_ACCOUNT_SID=..._11$ export TWILIO_API_KEY=..._11$ export TWILIO_API_SECRET=..._11$ docker run -it --rm \_11-e TWILIO_ACCOUNT_SID \_11-e TWILIO_API_KEY \_11-e TWILIO_API_SECRET \_11twilio/twilio-cli twilio phone-numbers:list_11_11SID Phone Number Friendly Name_11PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +15558675310 (555) 867-5310
See the Docker run reference guide for more information about setting container environment variables.
Since the Twilio CLI stores your profile settings on your local file system, it's possible to share those settings with the Docker container by using Volumes. Your profiles will be inherited by the Docker container, without the need to
To share your local configuration with the Docker container, mount your system's
~/.twilio-cli directory to the container at
/root/.twilio-cli using the
-v flag. See the Docker run reference guide for more information about the
On macOS and Linux, use:
_10$ docker run -it --rm \_10-v ~/.twilio-cli:/root/.twilio-cli \_10twilio/twilio-cli twilio phone-numbers:list_10_10SID Phone Number Friendly Name_10PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +15558675310 (555) 867-5310
There are multiple versions of the Twilio CLI Docker image that you can use. To run a specific version, append the desired tag to your
docker run command.
There are two types of tags:
latest - Sets the latest version of the Docker image, which we recommend. This is the default behavior of docker run, but you can choose to append it explicitly.
_10docker run -it --rm twilio/twilio-cli:latest bash
<major.minor.patch> - Sets the container to run using a specific version of the Docker image.
_10docker run -it --rm twilio/twilio-cli:2.36.1 bash
The latest Docker image is only downloaded to your machine on the first execution of
docker run. You need to manually pull the latest version of subsequent runs if you wish to use an updated image.
To download the latest Docker image and make it available locally, use:
_10docker pull twilio/twilio-cli
Now that you have the Twilio CLI Docker image installed and understand its use: