Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of docker compose and docker stack

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the use of docker compose and docker stack". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the use of docker compose and docker stack"?

Docker introduced swarm mode in 1.12, including a stack command, which seems to be similar in function, but there is a difference:

Docker compose:

Compose is an evolution of fig, python scripts, need to be installed separately, compose can be build image,compose needs to be installed separately, compose is more used in the dev environment.

Docker stack:

Stack is integrated into docker native CLI,go writing and does not support build image. Stack is more suitable for docker cloud environment and is used to manage clusters.

A stack is a collection of services, it can make your app run in the specified environment, a stack file is a YAML file, YAML file defines one or more services, and docker-compose.yml file is very similar, but and compose has a small extension. Although both use compose.yml files, there is a missing difference in the commands. Stack only supports swarm mode and only supports compose V3 format.

Stack configuration item

Image the image is used to deploy the service, which is the only mandatory keyautodestroy whether the container should be terminated when the service is stop. The default is no, and there can be three kinds of autoredeploy: no, on-success, and always. When image is in updated, whether the container of service should be automatically redeployed. Default is falsecap_add, cap_drop adds or removes container acp capabilities. You can view specific capabilities through man 7 capabilities. Cgroup_parent specifies an optional parent cgroupcommand to override the distribution of the command directive deployment_strategy container in image. Default is emptiest_node. It can be emptiest_node, high_availability, every_node. Devices device mapping list, like docker client using-- device effect, dns custom dns server, which can be an address or multiple list addresses dns_search custom DNS search domainsenvironment a list of environment variables, will be added to the environment variables of service. The definition here overrides the environment variable definition in image. Expose exposes the port, but it will not be published on host, it just can access extra_hosts on your nodes to increase hostname mapping, and labels increases container metadata just like docker client's-- add-host effect. Links connects to other service and net sets network mode. By default, only bridge and host modes are supported. Pid sets pid mode, ports exposure port, format is HOST:CONTAINER, or only specify container port. This will select a random port on host whether privileged will enable the same permissions as container and docker engine. The default is whether falserestart restarts container when service is stop, and the default is no. Can be no, on-failure, alwaysroles A roles list of docker api security_opt overrides whether the default labeling schemesequential_deployment container of container should be started and expanded one by one. The default is falsetags indicating deployment tags, which is used to select nodes to determine the number of container copies in which nodestarget_num_containers the service runs by default. The default is the path where 1volumes is mounted, and the format is HOST:CONTAINER or HOST:CONTAINER:ro. Specify the access mode volumes_from to mount all volumes# and docker run common key working_dir: / app entrypoint: / app/entrypoint.sh user: root hostname: foo domainname: foo.com mac_address: 02:42:ac:11:65:43 cpu_shares: 512 cpuset: 0 mem_limit: 100000m memswap_limit: 200000m privileged: true read_only: true stdin_open: true tty: true from another service

Configuration item not supported by stack: build external_links env_file

Thank you for your reading, the above is the content of "what is the use of docker compose and docker stack". After the study of this article, I believe you have a deeper understanding of the use of docker compose and docker stack, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report