Set up your environmentEstimated reading time: 3 minutes
In this step you install the Docker Cloud CLI so interact with the service using your command shell. This tutorial uses CLI commands to complete actions.
Install the Docker Cloud CLI
Install the docker-cloud CLI using the package manager for your system.
Run the CLI in a Docker container
If you have Docker Engine installed locally, you can run the following
command in your shell regardless of which operating system you are using.
docker run dockercloud/cli -h
This command runs the
docker-cloud CLI image in a container for you. Learn
more about how to use this container
Install for Linux or Windows
If you already have 2.x or Python 3.x installed, you probably have
setuptools, but will need to upgrade per the instructions here.
Now that you have
pip, open a shell or terminal
window and run the following command to install the docker-cloud CLI:
$ pip install docker-cloud
Install on macOS
We recommend installing Docker CLI for macOS using Homebrew. If you don’t have
brew installed, follow the instructions here: http://brew.sh
Once Homebrew is installed, open Terminal and run the following command:
$ brew install docker-cloud
Note: You can also use pip to install on macOS, but we suggest Homebrew since it is a package manager designed for the Mac.
Validate the CLI installation
Check that the CLI installed correctly, using the
docker-cloud -v command. (This command is the same for every platform.)
$ docker-cloud -v docker-cloud 1.0.0
You can now use the
docker-cloud CLI commands from your shell.
The documentation for the Docker Cloud CLI tool and API here.
login CLI command to log in to Docker Cloud. Use the username and password you used when creating your Docker ID. If you use Docker Hub, you can use the same username and password you use to log in to Docker Hub.
$ docker login Username: my-username Password: Login succeeded!
You must log in to continue this tutorial.
Set your username as an environment variable
For simplicity in this tutorial, we use an environment variable for your Docker Cloud username. If you will be copying and pasting the tutorial commands, set the environment variable using the command below. (Change
my-username to your username.)
If you don’t want to do this, make sure you substitute your username for $DOCKER_ID_USER whenever you see it in the example commands.
$ export DOCKER_ID_USER=my-username
If you are running the tutorial with an organization’s resources:
By default, the
docker-cloud CLI uses your default user namespace, meaning the
repositories, nodes, and services associated with your individual Docker ID
account name. To use the CLI to interact with objects that belong to an
organization, prefix these commands with
DOCKERCLOUD_NAMESPACE=my-organization, or set this variable as in the example below.
$ export DOCKERCLOUD_NAMESPACE=my-organization
See the CLI documentation for more information.
Next up, we’ll Prepare the app.