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

Detailed tutorial on installing SonarQube using Docker

Table of contents 1. Pull the image 1.1 Pull the ...

Nginx+FastDFS to build an image server

Installation Environment Centos Environment Depen...

JS realizes the case of eliminating stars

This article example shares the specific code of ...

Using CSS to implement loading animation of Android system

There are two common loading icons on the web, on...

Examples of using the Li tag in HTML

I hope to align the title on the left and the dat...

CentOS 7 installation and configuration method graphic tutorial

This article records the detailed installation tu...

How to configure Bash environment variables in Linux

Shell is a program written in C language, which i...

js to implement the snake game with comments

This article example shares the specific code of ...

How to run .sh files in Linux system

There are two ways to run .sh files in Linux syst...

Detailed Analysis of or, in, union and Index Optimization in MySQL

This article originated from the homework assignm...

Drop-down menu implemented by HTML+CSS3+JS

Achieve results html <div class="containe...

Tutorial on installing mysql5.7.23 on Ubuntu 18.04

This article shares with you the specific method ...