码头-组成上,下,停止启动差异

我找不到更多关于这些的信息。

我们是否应该对从 docker start开始的容器使用 docker stop

或者 docker-compose up也一样?

停止和下降有什么区别?

100013 次浏览

In docker-compose help

stop               Stop services


down               Stop and remove containers and networks (optionally images and volumes as well)
# Stop services only
docker-compose stop


# Stop and remove containers, networks..
docker-compose down


# Down and remove volumes
docker-compose down --volumes


# Down and remove images
docker-compose down --rmi <all|local>

Just to answer the other part of the question:

Use docker-compose up to start or restart all the services defined in a docker-compose.yml.

The docker-compose start command is useful only to restart containers that were previously created, but were stopped. It never creates new containers.

The docker-compose run command is for running “one-off” or “adhoc” tasks.

For further information visit this page.

Following are the differences among various docker-compose command options:

docker-compose up - start and restart all the services defined in docker-compose.yml

docker-compose down - command will stop running containers, but it also removes the stopped containers as well as any networks that were created. You can take down one step further and add the -v flag to remove all volumes too. This is great for doing a full blown reset on your environment by running docker-compose down -v.

docker-compose start - command will only restart containers stopped previously

docker-compose stop - command will stop running containers but won’t remove them