Deploy the app as a Docker Cloud service

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.

What you’ll do in this step is slightly different if you have Docker Engine installed locally or not. If you have Docker Engine installed locally, start at Deploy app with Docker Engine installed locally.

If you do not have Docker Engine installed locally, start at Deploy app without Docker Engine installed locally.

Note: If you don’t have Docker Engine installed locally, skip to

Deploy app with Docker Engine installed locally

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

Skip the next section and read about The run command.

Deploy app without Docker Engine installed locally

If you don’t have Docker Engine installed locally and you have been following this tutorial, you probably don’t have either of the quickstart images in your private registry in Docker Cloud. To deploy the service without Engine installed locally, use the public images dockercloud/quickstart-python or dockercloud/quickstart-go available on Docker Hub.

To do this execute one of the following commands:

Python quickstart

$ docker-cloud service run -p 80 --name web dockercloud/quickstart-python

Go quickstart

$ docker-cloud service run -p 80 --name web dockercloud/quickstart-go

Go to the next section to read about The run command.

The run command

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.

$ docker-cloud container ps
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.


Комментарии:

Комментариев нет, желаете стать первым?

Пожалуйста, авторизуйтесь что бы оставлять комментарии.