Deploying Swarm Deployments from Docker Compose
Deploying a complete environment is easy with Docker Swarm; you'll see that most of the work is already done if you have been running your containers using Docker Compose. This means you won't need to manually start services one by one in Swarm as we did in the previous section of this chapter.
If you already have a docker-compose.yml
file available to bring up your services and applications, there is a good chance it will simply work without issues. Swarm will use the stack deploy
command to deploy all your services across the Swarm nodes. All you need to do is provide the compose
file and assign the stack a name:
docker stack deploy --compose-file <compose_file> <swarm_name>
The stack creation is quick and seamless, but a lot is happening in the background to make sure all services are running correctly—including setting up networks between all the services and starting up each of the services...