Sunday, December 31, 2017

Docker Stack

What is Docker Stack ?
It is a collection of services that make up an application in a specific environment.
A stack file is a file in YAML format similar to docker-compose.yml , that defines one or more services

Why should we use it ?
  • convenient way to automatically deploy multiple services that are linked to each other.
  • Stack files define env variables , deployment tags , the number of containers and related environment specific configuration
  • Because of this you should use seperate stack file for dev , stage and production 

 sample command looks like



The Difference
Docker Compose is a Python project. Originally, there was a Python project known as fig which was used to parse fig.yml files to bring up stacks of Docker containers. Everybody loved it, especially the Docker folks, so it got reincarnated as docker compose to be closer to the product. But it was still in Python, operating on top of the Docker Engine.

You still have to install docker-compose separately to use it with Docker on your machine.

The Docker Stack functionality, is included with the Docker engine. You don’t need to install additional packages to use it Deploying docker stacks is part of the swarm mode. It supports the same kinds of compose files, but the handling happens in Go code, inside of the Docker Engine. You also have to create a one-machine “swarm” before being able to use the stack command, but that’ not a big issue.

Docker stack does not support docker-compose.yml files which are written according to the version 2 specification. It has to be the most recent one, which is 3.

The conclusion
As docker stack does everything docker compose does, it’s a safe bet that docker stack will prevail. This means that docker-compose will probably be deprecated and won’t be supported eventually.

However, switching your workflows to using docker stack is neither hard nor much overhead for most users. You can do it while upgrading your docker compose files from version 2 to 3 with comparably low effort.

If you’re new to the Docker world, or are choosing the technology to use for a new project - by all means, stick to using docker stack deploy.

No comments: