Prerequisites
- Install Docker.
- Read the orientation in Part 1.
- Learn how to create containers in Part 2.
- Make sure you have pushed the container you created to a registry, as instructed; we’ll be using it here.
- Ensure your image is working by running this and visiting
http://localhost/
(slotting in your info forusername
,repo
, andtag
):docker run -p 80:80 username/repo:tag
- Have the final version of
docker-compose.yml
from Part 5 handy.
Introduction
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 go through some options for running your Dockerized application.
Choose an option
If you’re okay with using Docker Community Edition in production, you can use Docker Cloud to help manage your app on popular cloud providers such as Amazon Web Services, DigitalOcean, and Microsoft Azure.
To set up and deploy:
- Connect Docker Cloud with your preferred provider, granting Docker Cloud permission to automatically provision and “Dockerize” VMs for you.
- Use Docker Cloud to create your computing resources and create your swarm.
- Deploy your app.
Note: We will be linking into the Docker Cloud documentation here; be sure to come back to this page after completing each step.
Connect Docker Cloud
First, link Docker Cloud with your cloud provider:
- Amazon Web Services setup guide
- DigitalOcean setup guide
- Microsoft Azure setup guide
- Packet setup guide
- SoftLayer setup guide
- Use the Docker Cloud Agent to Bring your Own Host
Create your swarm
After your cloud provider is all set up, create a Swarm:
- If you’re on AWS you can automatically create a swarm.
- Otherwise, create your nodes in the Docker Cloud UI, and run the
docker swarm init
anddocker swarm join
commands you learned in part 4 over SSH via Docker Cloud. Finally, enable Swarm Mode by clicking the toggle at the top of the screen, and register the swarm you just made.
Deploy your app
Connect to your swarm via Docker Cloud. This opens a terminal whose context is your local machine, but whose Docker commands are routed up to the swarm running on your cloud provider. This is a little different from the paradigm you’ve been following, where you were slinging commands via SSH; now, you can directly access both your local file system and your remote swarm, enabling some very tidy-looking commands:
docker stack deploy -c docker-compose.yml getstartedlab
That’s it! Your app is running in production and is managed by Docker Cloud.
Congratulations!
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.
No comments:
Post a Comment