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

Solve the problem that Docker pulls MySQL image too slowly

After half an hour of trying to pull the MySQL im...

Sample code of uniapp vue and nvue carousel components

The vue part is as follows: <template> <...

Detailed explanation of common Docker commands

1. Help Command 1. View the current Docker versio...

Detailed explanation of the use of the <meta> tag in HTML

In the web pages we make, if we want more people ...

MySQL 5.7.16 ZIP package installation and configuration tutorial

This article shares the installation and configur...

Detailed explanation of Excel parsing and exporting based on Vue

Table of contents Preface Basic Introduction Code...

mysql installer web community 5.7.21.0.msi installation graphic tutorial

This article example shares the specific code for...

Analysis of MySQL's method of exporting to Excel

This article describes how to use MySQL to export...

Linux file/directory permissions and ownership management

1. Overview of file permissions and ownership 1. ...

Summary of some related operations of Linux scheduled tasks

I have searched various major websites and tested...

Implementation steps for installing FTP server in Ubuntu 14.04

Table of contents Install Software Management Ano...