Detailed explanation of common Docker Compose commands

Detailed explanation of common Docker Compose commands

1. The use of Docker compose is very similar to the use of docker commands, but it should be noted that most compose commands need to be executed in the directory where the docker-compose.yml file is located.

2. Compose runs in daemon mode with the -d option

$ docker-compose up -d

3. Check which services are available and use the docker-compose ps command, which is very similar to the docker ps command

4. View the compose log

$ docker-compose logs web
$ docker-compose logs redis

5. Stop the compose service

$ docker-compose stop
$ docker-compose ps 


See that the service status is Exit

6. Restart the compose service

$ docker-compose restart
$ docker-compose ps 

7. Kill the compose service

$ docker-compose kill
$ docker-compose ps 


Status code is 137

8. Delete the compose service

$ docker-compose rm 

9. More docker-compose commands can be viewed using docker-compose --help

docker-compose --help You will see the following commands

build Build or rebuild services

bundle Generate a Docker bundle from the Compose file

config Validate and view the Compose file

create Create services

down Stop and remove containers, networks, images, and volumes

events Receive real time events from containers

exec Execute a command in a running container

help Get help on a command

images List images

kill Kill containers

logs View output from containers

pause Pause services

port Print the public port for a port binding

ps List containers

pull Pull service images

push service images

restart Restart services

rm Remove stopped containers

run Run a one-off command

scale Set number of containers for a service

start Start services

stop Stop services

top Display the running processes

unpause Unpause services

up Create and start containers

version Show the Docker-Compose version information

docker-compose up -d nginx builds and starts the nginx container

docker-compose exec nginx bash logs into the nginx container

docker-compose down deletes all nginx containers and images

docker-compose ps shows all containers

docker-compose restart nginx restarts the nginx container

docker-compose run --no-deps --rm php-fpm php -v does not start the associated container in php-fpm, and the container executes php -v and deletes the container after execution.

docker-compose build nginx builds the image.

docker-compose build --no-cache nginx Build without cache.

docker-compose logs nginx View nginx logs

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

docker-compose config -q verifies the (docker-compose.yml) file configuration. When the configuration is correct, nothing is output. When the file configuration is incorrect, an error message is output.

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

docker-compose pause nginx pause nginx container

docker-compose unpause nginx restore ningx container

docker-compose rm nginx deletes the container (the container must be closed before deletion)

docker-compose stop nginx Stop the nginx container

docker-compose start nginx starts the nginx container

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Two simplest ways to install docker-compose
  • Docker Compose Tutorial
  • Detailed examples of using Docker-Compose
  • Detailed installation and use of docker-compose
  • Detailed explanation of how to use Docker-Compose commands
  • Docker compose configuration file writing and command usage examples

<<:  mysql solves the problem of finding records where two or more fields are NULL

>>:  Drawing fireworks effect of 2021 based on JS with source code download

Recommend

vue3.0+echarts realizes three-dimensional column chart

Preface: Vue3.0 implements echarts three-dimensio...

Install .NET 6.0 in CentOS system using cloud server

.NET SDK Download Link https://dotnet.microsoft.c...

Solution to forgetting mysql password under linux

The problem is as follows: I entered the command ...

Detailed explanation of the watch listener example in vue3.0

Table of contents Preface The difference between ...

Using js to realize dynamic background

This article example shares the specific code of ...

Why Use DOCTYPE HTML

You know that without it, the browser will use qui...

MySQL solution for creating horizontal histogram

Preface Histogram is a basic statistical informat...

MySQL Index Detailed Explanation

Table of contents 1. Index Basics 1.1 Introductio...

Detailed explanation of the use of ElementUI in Vue

Login + sessionStorage Effect display After a suc...

CentOS 6 Compile and install ZLMediaKit analysis

Install ZLMediaKit on centos6 The author of ZLMed...

A brief discussion on the use of React.FC and React.Component

Table of contents 1. React.FC<> 2. class xx...

Chinese website user experience rankings

<br />User experience is increasingly valued...