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

How to understand the Docker compose orchestration tool

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

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to understand the Docker compose choreography tool". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Docker Compose

Docker Compose is a tool that defines and runs multiple Docker containers. Through Compose, you don't need to start the container with the shell script, but use the YAML file to configure all the services needed by the application, and then use the command to create and start all services according to the file configuration of YAML, which is very suitable for multiple container development scenarios.

Compose is well suited for development, testing and staging environments as well as CI workflows.

YAML

YAML is a highly readable format for expressing data serialization

Related orders and formats

Version: specify the version of compase on which the yml file is based services: specify the service options for creating the container service name: such as nginx: container hostname build: specify the build image context path context: context path dockerfile: specify the Dockerfile file name of the build image Ports: expose container port Same as-p, but the port cannot be less than 60 For example:-1234Swarm 80 networks: join the network deploy configured under the top-level networks: specify the configuration related to the deployment and running services. You can only use volumes: mount the host path or command volume image in Swarm mode: specify the image of the container to run: execute the command, override the default command container_name: specify the container name. Since the container name is unique, if you specify a custom name, you cannot scale (extend) environment: add environment variable restart: restart policy, define whether to restart the container No (default, do not restart), always (always restart), no-failure (restart when the exit status is not 0), unless-stoped (ignore the container stopped before the daemon is started when the container exits) networks: configure the network, specify the network card device, etc.

Compose command

Basic use format docker-compose [options] [COMMAND] [ARGS...] Option-- verbose: output more debug information-- version: print the version and exit-- fmaine compose FILE: use a specific compose template file, default is docker-compose.yml-p,-- project-name NAME: specify the project name Default use directory name common commands build rebuild service ps list container up create and start container exec execute the command scale in the container to specify the number of service container startup top display the container process logs view the output of the service container down delete container, network, Data volume and mirror stop/start/restart stop / start / restart service

Compose installation

# Environment deployment all hosts install docker environment (content is docker foundation) yum install docker-ce-y # download compose, which can be downloaded directly via curl link Or drag it into linuxcrul. # give docker compose execution permission cp-p docker-compose / usr/local/bin/chmod + x / usr/local/bin/docker-composemkdir / root/compose_nginx# to create a container using compose choreography # write a yml file vim / root/compose_nginx/docker-compose.ymlversion: '3'services: nginx: hostname: nginx build: context:. / nginx dockerfile: Dockerfile ports: Networks:-cluster volumes: -. / wwwroot:/usr/local/nginx/htmlnetworks: cluster:# put in the related file mkdir nginxmkdir wwwrootecho "this is nginx" > wwwroot/index.html# execute yml file creation container docker-compose-f docker-compose.yml up-d "how to understand the Docker compose orchestration tool" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Development

Wechat

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

12
Report