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

Let's learn about the MySQL storage engine

Table of contents Preface 1. MySQL main storage e...

Analysis of the principles of Mysql dirty page flush and shrinking table space

mysql dirty pages Due to the WAL mechanism, when ...

How to shrink the log file in MYSQL SERVER

The transaction log records the operations on the...

How to implement draggable components in Vue

This article shares with you how to implement dra...

Use Nginx to build a streaming media server to realize live broadcast function

Written in front In recent years, the live stream...

Summary of relevant knowledge points of ajax in jQuery

Preface Students who learn JavaScript know that A...

Detailed explanation of monitoring NVIDIA GPU usage under Linux

When using TensorFlow for deep learning, insuffic...

Ideas and codes for implementing Vuex data persistence

What is vuex vuex: is a state manager developed s...

How to implement MySQL bidirectional backup

MySQL bidirectional backup is also called master-...

Installation and use tutorial of Elasticsearch tool cerebro

Cerebro is an evolution of the Elasticsearch Kopf...