Docker Compose installation and usage steps

Docker Compose installation and usage steps

1. What is Docker Compose?

  1. Docker Compose is a tool for defining and running multi-container applications.
  2. Docker Compose defines multi-container Docker applications through yml files;
  3. Docker Compose uses a single command to create or manage multiple containers based on the definition of a yml file;
  4. Docker Compose is used for multi-container control of Docker and is a tool used to automate Docker. With Docker Compose, you can automate all complex Docker operations with just one command (which can be simply understood as batch processing).

2. Docker Compose installation steps

1. Download the Docker Compose binary file. The version I downloaded here is 1.29.2

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2. Add executable permissions to the binary file just downloaded

sudo chmod +x /usr/local/bin/docker-compose

3. Check whether the installation is successful through the docker-compose --version command

3. Docker Compose version differences

  1. The v3 version does not support attributes such as volume_from, extends, and group_add;
  2. The settings of cpu and memory properties are moved to deploy;
  3. The v3 version supports Docker Swarm, while the v2 version does not;

Note: The official has introduced a new --compatibility flag in 1.20.0 to help developers easily transition to v3. There are still some issues that the official does not recommend using directly in production. It is recommended that you directly use the v3 version.

4. Docker Compose basic commands

The Docker Compose command is basically the same as Docker, mainly for Docker Compose lifecycle control, log format and other related commands. You can view the help through docker-compose --help.

#Build and start the nginx container docker-compose up -d nginx                     

#Enter the nginx container docker-compose exec nginx bash            

#The container started by the UP command will be stopped and the container will be deleted docker-compose down                             

#Show all containers docker-compose ps                                   

#Restart the nginx container docker-compose restart nginx                   

#Build nginx image docker-compose build nginx      

#Build nginx image without cache docker-compose build --no-cache nginx 

#View nginx logs docker-compose logs nginx                      

#View nginx's real-time logs docker-compose logs -f nginx                   

#Verify (docker-compose.yml) file configuration,
#When the configuration is correct, nothing is output. When the file configuration is wrong, error information is output docker-compose config -q                        

#Output nginx's docker log in json format docker-compose events --json nginx       

#Pause the nginx container docker-compose pause nginx                 

#Restore ningx container docker-compose unpause nginx             

#Delete the nginx container docker-compose rm nginx                       

#Stop the nginx container docker-compose stop nginx                    

#Start the nginx container docker-compose start nginx

5. For use cases, please refer to "Hand-in-hand teaching you to build gitlab community Chinese version with Docker"

This is the end of this article about the installation and use of Docker Compose. For more information about the installation and use of Docker Compose, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • A brief discussion on how to solve the depends_on order problem in Docker-compose
  • Practical notes on installing Jenkins with docker-compose
  • Detailed process of getting started with docker compose helloworld
  • Detailed explanation of the Sidecar mode in Docker Compose

<<:  Vue.js handles Icon icons through components

>>:  10 Things Excellent Web Developers Must Know to Improve Their Development Skills

Recommend

Detailed explanation of the data responsiveness principle of Vue

This article is mainly for those who do not under...

How to shut down/restart/start nginx

closure service nginx stop systemctl stop nginx s...

HTML table markup tutorial (4): border color attribute BORDERCOLOR

To beautify the table, you can set different bord...

mysql group_concat method example to write group fields into one row

This article uses an example to describe how to u...

Problems installing TensorRT in docker container

Uninstall the installed version on Ubuntu: sudo a...

MySQL 5.7.25 installation and configuration method graphic tutorial

There are two types of MySQL installation files, ...

What is TypeScript?

Table of contents 1. JavaScript issues 2. Advanta...

Implementation of waterfall layout + dynamic rendering

Table of contents Typical waterfall website Water...

Tips for implementing list loop scrolling based on jQuery (super simple)

I saw a good idea and recorded it. I have used jQ...

Detailed steps to install CentOS7 system on VMWare virtual machine

Pre-installation work: Make sure vmware workstati...

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

After IntelliJ IDEA deploys a Javaweb project usi...

A brief analysis of the use of the HTML webpack plugin

Using the html-webpack-plugin plug-in to start th...