Detailed explanation of Docker compose orchestration tool

Detailed explanation of Docker compose orchestration tool

Docker Compose

Docker Compose is a tool for defining and running multiple Docker containers. With Compose, there is no need to use shell scripts to start containers. Instead, you can use YAML files to configure all the services required by the application, and then use commands to create and start all services according to the YAML file configuration. This is very suitable for scenarios where multiple containers are developed.

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 commands and formats

version: specifies the version of compase that this yml file is based on services: specifies the service options for creating containers Service name: for example, nginx, etc. hostname: container host name build: specifies the context path for building the image context: context path dockerfile: specifies the Dockerfile file name for building the image ports: exposes the container port, the same as -p, but the port cannot be lower than 60; for example: - 1234:80
		networks: join the network configured under the top-level networks deploy: specify the configuration related to deploying and running services, which can only be used in Swarm mode volumes: mount the host path or command volume image: specify the image running the container command: execute the command, overwrite the default command container_name: specify the container name. Since the container name is unique, if a custom name is specified, it cannot be scaled
	environment: Add environment variables restart: Restart strategy, define whether to restart the container; no (default, do not restart), always (always restart),
no-failure (restart when exit status is not 0), unless-stoped (when the container exits, ignore the container that was stopped before the daemon process started)
Networks: configure the network, specify network card devices, etc.

Compose command

The basic usage format is docker-compose [options] [COMMAND] [ARGS...]

Options --verbose: Output more debugging information --version: Print version and exit -f, --file FILE: Use a specific compose template file, default is docker-compose.yml
-p, --project-name NAME: specifies the project name. By default, the directory name is used. Common commands build Rebuild the service ps List containers up Create and start containers exec Execute commands in the container scale Specify the number of service containers to start top Display the running container processes logs View the output of the service container down Delete containers, networks, data volumes, and images stop/start/restart Stop/start/restart the service

Compose installation

#Environment deployment All hosts install the docker environment (the content is docker basics)
yum install docker-ce -y

#Download compose, you can download it directly through curl link, or drag it into linux after downloading it outside
crul......

#Give docker compose execution permission cp -p docker-compose /usr/local/bin/
chmod +x /usr/local/bin/docker-compose

mkdir /root/compose_nginx


#Use compose to create a container#Write the yml file vim /root/compose_nginx/docker-compose.yml
version: '3'
services:
  nginx:
    hostname: nginx
    build:
      context: ./nginx
      dockerfile: Dockerfile
    ports:
     - 1216:80
     - 1217:443
    networks:
     - cluster
    volumes:
     - ./wwwroot:/usr/local/nginx/html
networks:
  cluster:

#Put in relevant files mkdir nginx
mkdir wwwroot
echo "this is nginx" > wwwroot/index.html

#Execute the yml file to create a container docker-compose -f docker-compose.yml up -d

This is the end of this article about the detailed explanation of the Docker compose orchestration tool. For more relevant content about the Docker compose orchestration tool, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to install and configure the Docker Compose orchestration tool in Docker.v19
  • Detailed explanation of Docker Compose service orchestration
  • How to use Docker compose to orchestrate Laravel applications
  • Docker container orchestration tool Compose (Getting Started)
  • Docker series: Using Docker Compose to orchestrate containers

<<:  Several common methods for setting anchor positioning in HTML

>>:  MySQL database Load Data multiple uses

Recommend

The pitfall record of the rubber rebound effect of iOS WeChat H5 page

Business requirements One of the projects I have ...

CSS to achieve Cyberpunk 2077 style visual effects in a few steps

background Before starting the article, let’s bri...

HTML sub tag and sup tag

Today I will introduce two HTML tags that I don’t...

About the layout method of content overflow in table

What is content overflow? In fact, when there is ...

impress.js presentation layer framework (demonstration tool) - first experience

I haven’t blogged for half a year, which I feel a ...

Where is the project location deployed by IntelliJ IDEA using Tomcat?

After IntelliJ IDEA deploys a Javaweb project usi...

Trash-Cli: Command-line Recycle Bin Tool on Linux

I believe everyone is familiar with the trashcan,...

How to use @media in mobile adaptive styles

General mobile phone style: @media all and (orien...

A "classic" pitfall of MySQL UPDATE statement

Table of contents 1. Problematic SQL statements S...

js canvas realizes circular water animation

This article example shares the specific code of ...

Implementation of React configuration sub-routing

1. The component First.js has subcomponents: impo...

Vue implements a simple calculator

This article example shares the specific code of ...

How to encapsulate axios request with vue

In fact, it is very simple to encapsulate axios i...

Implementation of react automatic construction routing

Table of contents sequence 1. Centralized routing...