Movatterモバイル変換


[0]ホーム

URL:


Skip to contentSkip to navigationSkip to topbar
Go to the Twilio Docs home page
Twilio Docs

Use the Twilio CLI Docker image


Theofficial Docker image(link takes you to an external page) 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.


In order to utilize the CLI Docker image, you will need to make sure you haveDocker(link takes you to an external page) installed and running on your system. For installation instructions, see theDocker website(link takes you to an external page).


To run the Twilio CLI Docker image with an interactive bash shell, use:

dockerrun-it --rmtwilio/twilio-cli bash

Once the container has finished downloading, and you have entered the shell, you can issue commands using the CLI. For example:

1
$docker run-it --rmtwilio/twilio-cli bash
2
3
root@1234:/twilio#twilio profiles:list
4
IDAccount SID Active
5
youACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXtrue
6
mainACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXfalse

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:

1
$docker run-it --rmtwilio/twilio-cli twilio--version
2
twilio-cli/3.0.0linux-x64 node-v14.18.1

Provide credentials and configuration

provide-credentials-and-configuration page anchor

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 usetwilio login on each run.

Via environment variables

via-environment-variables page anchor

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:

1
$export TWILIO_ACCOUNT_SID=...
2
$export TWILIO_API_KEY=...
3
$export TWILIO_API_SECRET=...
4
$docker run-it --rm \
5
-eTWILIO_ACCOUNT_SID\
6
-eTWILIO_API_KEY\
7
-eTWILIO_API_SECRET\
8
twilio/twilio-cli twilio phone-numbers:list
9
10
SIDPhone Number Friendly Name
11
PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+15558675310(555) 867-5310

See theDocker run reference guide(link takes you to an external page) 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 usingVolumes(link takes you to an external page). Your profiles will be inherited by the Docker container, without the need tologin.

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 theDocker run reference guide(link takes you to an external page) for more information about the-v flag.

macOS and LinuxWindows PowerShell

On macOS and Linux, use:

1
$docker run-it --rm \
2
-v~/.twilio-cli:/root/.twilio-cli\
3
twilio/twilio-cli twilio phone-numbers:list
4
5
SIDPhone Number Friendly Name
6
PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX+15558675310(555) 867-5310

Run a specific version or tag

run-a-specific-version-or-tag page anchor

There are multiple versions of the Twilio CLI Docker image that you can use. To run a specific version, append the desired tag to yourdocker 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.

    dockerrun-it --rmtwilio/twilio-cli:latest bash
  • <major.minor.patch> - Sets the container to run using a specific version of the Docker image.

    dockerrun-it --rmtwilio/twilio-cli:2.36.1 bash

Update to the latest Docker image

update-to-the-latest-docker-image page anchor

The latest Docker image is only downloaded to your machine on the first execution ofdocker 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:

dockerpull twilio/twilio-cli

Now that you have the Twilio CLI Docker image installed and understand its use:


[8]ページ先頭

©2009-2025 Movatter.jp