|
||||||||||||||||
Docker, Get Started 6
Время создания: 22.01.2018 09:56
Текстовые метки: docker start tutorial
Раздел: Docker
Запись: Velonski/mytetra-database/master/base/15165969894ul98sig0a/text.html на raw.githubusercontent.com
|
||||||||||||||||
|
||||||||||||||||
You’ve been editing the same Compose file for this entire tutorial. Well, we have good news. That Compose file works just as well in production as it does on your machine. Here, we’ll go through some options for running your Dockerized application.
If you’re okay with using Docker Community Edition in production, you can use Docker Cloud to help manage your app on popular service providers such as Amazon Web Services, DigitalOcean, and Microsoft Azure. To set up and deploy:
Note: We will be linking into the Docker Cloud documentation here; be sure to come back to this page after completing each step. You can run Docker Cloud in standard mode or in Swarm mode . If you are running Docker Cloud in standard mode, follow instructions below to link your service provider to Docker Cloud.
If you are running in Swarm mode (recommended for Amazon Web Services or Microsoft Azure), then skip to the next section on how to create your swarm . Ready to create a swarm?
Note: If you are Using the Docker Cloud Agent to Bring your Own Host , this provider does not support swarm mode. You can register your own existing swarms with Docker Cloud. Deploy your app on a cloud provider
Or …
Either way, this opens a terminal whose context is your local machine, but whose Docker commands are routed up to the swarm running on your cloud service provider. You directly access both your local file system and your remote swarm, enabling pure docker commands. docker stack deploy -c docker-compose.yml getstartedlab Creating network getstartedlab_webnet Creating service getstartedlab_web Creating service getstartedlab_visualizer Creating service getstartedlab_redis
Your app is now running on your cloud provider. Run some swarm commands to verify the deployment You can use the swarm command line, as you’ve done already, to browse and manage the swarm. Here are some examples that should look familiar by now:
[getstartedlab] ~ $ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 9442yi1zie2l34lj01frj3lsn ip-172-31-5-208.us-west-1.compute.internal Ready Active jr02vg153pfx6jr0j66624e8a ip-172-31-6-237.us-west-1.compute.internal Ready Active thpgwmoz3qefdvfzp7d9wzfvi ip-172-31-18-121.us-west-1.compute.internal Ready Active n2bsny0r2b8fey6013kwnom3m * ip-172-31-20-217.us-west-1.compute.internal Ready Active Leader
[getstartedlab] ~/sandbox/getstart $ docker service ls ID NAME MODE REPLICAS IMAGE PORTS x3jyx6uukog9 dockercloud-server-proxy global 1/1 dockercloud/server-proxy *:2376->2376/tcp ioipby1vcxzm getstartedlab_redis replicated 0/1 redis:latest *:6379->6379/tcp u5cxv7ppv5o0 getstartedlab_visualizer replicated 0/1 dockersamples/visualizer:stable *:8080->8080/tcp vy7n2piyqrtr getstartedlab_web replicated 5/5 sam/getstarted:part6 *:80->80/tcp
[getstartedlab] ~/sandbox/getstart $ docker service ps vy7n2piyqrtr ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS qrcd4a9lvjel getstartedlab_web.1 sam/getstarted:part6 ip-172-31-5-208.us-west-1.compute.internal Running Running 20 seconds ago sknya8t4m51u getstartedlab_web.2 sam/getstarted:part6 ip-172-31-6-237.us-west-1.compute.internal Running Running 17 seconds ago ia730lfnrslg getstartedlab_web.3 sam/getstarted:part6 ip-172-31-20-217.us-west-1.compute.internal Running Running 21 seconds ago 1edaa97h9u4k getstartedlab_web.4 sam/getstarted:part6 ip-172-31-18-121.us-west-1.compute.internal Running Running 21 seconds ago uh64ez6ahuew getstartedlab_web.5 sam/getstarted:part6 ip-172-31-18-121.us-west-1.compute.internal Running Running 22 seconds ago
Open ports to services on cloud provider machines At this point, your app is deployed as a swarm on your cloud provider servers, as evidenced by the docker commands you just ran. But, you still need to open ports on your cloud servers in order to:
These are the ports you need to expose for each service:
Methods for doing this will vary depending on your cloud provider. We’ll use Amazon Web Services (AWS) as an example. What about the redis service to persist data? To get the redis service working, you need to ssh into the cloud server where the manager is running, and make a data/ directory in /home/docker/ before you run docker stack deploy. Another option is to change the data path in the docker-stack.yml to a pre-existing path on the manager server. This example does not include this step, so the redis service is not up in the example output.
You’ll see security groups related to your swarm for getstartedlab-Manager-<xxx>, getstartedlab-Nodes-<xxx>, and getstartedlab-SwarmWide-<xxx>.
Tip: When you save the new rules, HTTP and TCP ports will be auto-created for both IPv4 and IPv6 style addresses.
Just as in the previous parts of the tutorial, the Hello World app displays on port 80, and the Visualizer displays on port 8080.
From here you can do everything you learned about in previous parts of the tutorial.
docker stack rm getstartedlab
Unlike the scenario where you were running the swarm on local Docker machine VMs, your swarm and any apps deployed on it will continue to run on cloud servers regardless of whether you shut down your local host. You’ve taken a full-stack, dev-to-deploy tour of the entire Docker platform. There is much more to the Docker platform than what was covered here, but you have a good idea of the basics of containers, images, services, swarms, stacks, scaling, load-balancing, volumes, and placement constraints. Want to go deeper? Here are some resources we recommend:
|
||||||||||||||||
Так же в этом разделе:
|
||||||||||||||||
|
||||||||||||||||
|