In this step you will deploy the app as a Docker Cloud Service. Remember that a service is a group of containers of the same image:tag.
Note: 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 withDOCKERCLOUD_NAMESPACE=my-organization
. See the CLI documentation for more information.
Start by running the service.
$ docker-cloud service run -p 80 --name web $DOCKER_ID_USER/quickstart-python
or
$ docker-cloud service run -p 80 --name web $DOCKER_ID_USER/quickstart-go
The run
command creates and runs the service using the image you chose.
The -p 80 flag publishes port 80 in the container so that it is publicly
accessible, and maps it to a dynamically assigned port in the node.
It might take a minute or two to get your service up and running. Once it completes the startup process, it will be in the running state.
To check the status of your service from the CLI use the docker-cloud service ps
command.
$ docker-cloud service ps
NAME UUID STATUS IMAGE DEPLOYED
web 68a6fb2c ▶ Running my-username/quickstart-python:latest 1 hour ago
Make sure that the STATUS for your service is Running. Next, visit the
app at the URL generated by its service name. Find this URL by running
docker-cloud container ps --no-trunc
.
$ docker-cloud container ps --no-trunc
NAME UUID STATUS IMAGE RUN COMMAND EXIT CODE DEPLOYED PORTS
web-1 6c89f20e ▶ Running my-username/quickstart-python:latest python app.py 1 minute ago web-1.my-username.cont.dockerapp.io:49162->80/tcp
The PORTS column contains the URL you can use to see the service running in
a browser. Copy the URL, open a browser, and go to that URL. In the example above, the URL is
web-1.my-username.cont.dockerapp.io:49162
.
If you don’t want to leave the command line, you can use the curl
command instead.
$ curl web-1.$DOCKER_ID_USER.cont.dockerapp.io:49162
Hello World!</br>Hostname: web-1</br>Counter: Redis Cache not found, counter disabled.%
Tip: Your Docker ID is used as part of the namespace when running containers in Docker Cloud. In the example above, instead of copying the URL entirely, you can see we used the $DOCKER_ID_USER variable.
CONGRATULATIONS! You’ve deployed your first service using Docker Cloud.
Next: Define environment variables.