Docker Compose and Docker Stack differences

Original translation

Docker engine in version 1.12 with integrated Docker Swarm, brought some new tools.

Now you can without having to install Docker Compose, you can create a Docker container stack using the docker-compose.yml file.

This order is docker stack, using docker-compose similar manner, the following are examples:

$ docker-compose -f docker-compose up

$ docker stack deploy -c docker-compose.yml somestackname

Using substantially the same manner, these two commands can manipulate file docker-compose.yml defined docker services, volumes, networks and the like.

But why this happens, and Docker Stack and Docker Compose any different? Why introduce? In addition to grammar, what is different?

Representation of different points

① docker stack ignores the docker-compose the "build" command, you can not create a mirror in the stack command. Docker stack needs to be mirrored already exist, and therefore more suitable for the development docker compose occasions.

② docker stack, docker-compose each file will be ignored docker-compose.yml some instructions, please this page search "ignore" for more details.

Birth of the first difference

docker-compose a Python project. Initially there is a Python project named fig able to resolve fig.yml ------- start docker container stack.

Everyone liked this tool, especially forkers github fork of this project, this tool slowly and renamed the product of docker-compose,

But it always is a Python tool, the top-level role in Docker engine .

  Internally, it uses Docker API to start a container according to the specification, you still have to install a separate docker-compose before it can be used on your computer with the Docker.

------------------------------------------###-------------------------------------------------

the ability to source from inside docker docker stack engine , you do not need to install additional kit to start the docker container stack (docker stack is part of the docker swarm of).

docker stack support and docker-compose similar capabilities, but the engine is running in the Docker Go locale before using docker stack command you must also create a swarm machine (this is not a problem).

docker stack does not support the version 2 specification write a docker-compose.yml file, you must use the latest version 3.0+. docker-compose tool can still handle version 2,3 (as mentioned above, will ignore certain instructions no longer apply to the tool).

in conclusion

docker stack and docker-compose can be applied on a docker-compose.yml file version 3 written in previous versions of 3 docker-compose.yml file can continue to use docker-compose tools,

If you want to upgrade, it will not take much time.

Because docker stack can do almost everything docker-compose, if you intend to use docker swarm manipulating containers, you can try docker stack.

If you only need a tool capable of operating multiple containers, you can still use docker-compose tool.

My point of view

Now docker-compose.yml version 3 is coupled with some docker stack, and even some bundles.

The bundle is not only reflected in the instructions docker-compose version 3 page "Ignore" is:

   build、cap_add, cap_drop、external_links 等

It also includes two common features:

restart_policy instruction: This container is in deploy automatically restart instruction following the instruction in version 3, it must deploy instruction bundle docker stack, resulting in version 3 is not written docker-compose.yml primary container automatically restart. F ** K '

env file :: docker-compose tool to identify and apply the default .env environment variable file in the same directory, but the common feature is now being ignored in the docker stack instruction.

The company wanted to let everyone guess Docker use docker stack at the time the application docker-compose version 3 (docker stack is part of the docker swarm of),

In Kubernetes has become the de facto standard in the case of a cluster container arrangement, Docker company in a vain attempt by the docker-compose.yml version 3 file Docker Swarm tied to expanding Docker Swarm market share.

So my advice is if you want to get started Kubernetes, I can ignore docker stack command, because you want to upgrade docker-compose version 3 files to the environment is not so simple Docker Swarm imagination.

 

Original:  https://vsupalov.com/difference-docker-compose-and-docker-stack/

 

Guess you like

Origin www.cnblogs.com/JulianHuang/p/11599170.html