View the webinar on-demand to learn:
- New deployment features in Docker Compose Version 3
- How to use new Compose V3 features to deploy apps on a Swarm Cluster
- Live Demo: How to Deploy on a local development cluster (Powered by Docker for Mac/Windows, Docker Compose V3 and Docker-in-docker)
Highlights of Alexei’s Talk:
Docker 4 Mac/Windows
Docker launched Docker for Mac/ Windows last year to provide native platform capabilities and a uniform experience across all platforms. Docker for Mac and Windows provides the full Docker development environment out-of-the-box, including the native Docker Client, Docker daemon (running inside a small virtual machine), Docker Notary, and Docker Compose, so you have everything you need.
- Easy installation and setup of a complete Docker development environment
- Fast and reliable performance with native macOS virtualization (xhyve for OS X) or native Windows Hyper V virtualization (for Windows) running a custom minimal Linux distro (Alpine)
- Seamless volume mounting for code and data, including file change notifications that unlock fast edit-test cycles
- Excellent network support allows working transparently with VPNs and proxies
- Multi-CPU Architecture Support: arm, mips, ppc64le and even s390x (Mac only)
Docker Swarm mode was introduced about a year ago in Docker 1.12. Before that, it was possible to create a Swarm cluster with some key values but difficult to do. A Swarm is a cluster of Docker machines where you have one or more Swarm masters and multiple worker machines. Ideally, you’d like to link them together to a single cluster and be able to deploy your app on this cluster.
The Old Way
Before Swarm mode, you needed to create proper certificates and keys, install the console discovery service, start the console agent on the each machine, properly set up all the certificates, and launch each node with all the proper parameters to connect in a swarm cluster. It was possible but was a huge headache.
The New Way
Now you just run Docker Swarm on your master machine, take the token (unique ID), and on the other Docker machine, run the
docker swarm join command to pass the token. And that’s it! It will combine both machines on that cluster.
New Deployment Features
New command with Docker 1.13 that allows us to easily deploy our Docker Compose file called
docker stack deploy.
$ docker stack deploy --compose-file docker-compose.yml myapp
The Difference between docker stack deploy and docker-compose up
The Docker client has a built-in parser for the docker-compose.yaml format. It can read the new Docker Compose V3 format including the new deploy section, and deploy what’s described in it. So you can use your Docker Compose file to deploy a Compose application on a swarm cluster.
The docker-compose CLI is a python based application that also understands docker-compose.yaml version 3. It has its own parser implemented but it totally ignores the deploy section. So it doesn’t know how to deploy a Compose file on a swarm cluster. The main difference between the two is that the docker-compose CLI only sees half of the compose file. So if you need to use it for testing and deployment, use the Docker client.
- docker client has a built-in docker-compose.yaml v3.x parser
- docker client reads deploy section to deploy a service on swarm cluster
- docker-compose CLI tool also has a built-in docker-compose.yaml v3.x parser
- docker-compose CLI tool ignores deploy section and does not deploy on swarm cluster
- docker-compose CLI tool works against single Docker host only
Compose v3 `deploy`
Before Compose Version 3 (introduced with Docker 1.13) you could do the same things (create services, networks, and volumes on a swarm cluster using the Docker client. But the biggest update in Docker Compose V3 is the feature of stack deployment with swarm. They introduced a new deploy key under the service node.
- mode -This allows you to specify how this service is deployed (if it’s global or replicated)
- placement – constraints- this allows you to define where your service is going or needs to be placed (node.id/hostname/role/labels, engine.labels)
- update_config -allows you to specify how this update should be executed (parallelism, delay, failure_action, monitor, max_failure_ratio)
- resources – enables you to limit resources, allocate a CPU quota, memory limit, etc. (cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit, mem_swappiness)
- restart_policy -what to do if service fails- condition, delay, max_attempts, window
- labels – can specify labels for each service
(See demo – 19 minutes 05 seconds of the webinar)
In the demo, Alexei showed us how to can create a Docker swarm cluster on a single machine. The demo app he deployed on swarm cluster can be found here:
We encourage you to go and clone it to try by yourself!
- Sign up for a free account at Codefresh.io & request a one-on-one onboarding session
- Visit our subscribe to our newsletter – https://codefresh.io/blog
- Docker’s documentation is a great resource to help you get started- https://docs.docker.com/
- Join our next in-person or online event
- Email with questions, feedback, or webinar topic requests at email@example.com