6.3 installation and basic use of docker compose

Time:2021-10-27

https://docs.docker.com/compose/install/#install-compose

Create and start the container

Docker compose will be found in the current directory by defaultdocker-compose.ymlfile

docker-compose up

With the – D parameter, it can be executed in the background, so as not to output log all the time, resulting in failure to exit

Start service

docker-compose  start

Out of Service

docker-compose stop

Stop and remove the container

Docker compose down will only destroy the container, not the volume data attached to the container

docker-compose down

matters needing attention

  • When we changeddocker-compose.ymlThe configuration in the file, for example, specifies a new version of the image, usingdocker-compose  restartIt cannot take effect and needs to be useddocker-compose up -d
  • If you are using a link so that the nginx container can access another container, configure it in the nginx containerproxy_pass http://other_container_nameIf so, other_ container_ Name equals when creating the nginx container  --linkThe container name followed by is equal to service in docker-compose.yml_ name。 In the docker-compose.yml file, docker-compose will automatically generate a container_ Name, so do we need to configure the container specifically_ The value of the name field becomes dispensable.