You may want to recoup the resources used by your projects containers and the docker host for other things if you are done with development for a while. You can stop the containers for a single project only or all containers and the docker host depending on what you are finished using.
-
If you only want to stop the containers for your project, in the project directory, run docker-compose stop or press Ctrl-C to stop a docker-compose process running in the foreground and then run docker-compose stop to ensure the project containers have stopped.
-
If you want to shut down the docker host as well as any containers, run devtools stop
Cleaning Up
From time to time you'll want to clean up stopped containers. You'll also want to take special care when finishing a project to release all the resources used by it.
For periodic cleanup of all stopped containers, run the following script while your docker host is running: devtools prune
If you only want to clean up project specific stopped containers, you can run: docker-compose rm from your project directory.
When you are finished with a project, if you used any persistent data storage you'll want to run a command to clean it up. The exact directory to request removal from will depend on your project [see suggested directory naming guidelines in Common Setup]: docker ssh dev sudo rm -rf /data/[project]/
BitBucket « Previous Next »
The docker-compose stop command will stop your containers, but it won’t remove them. The docker-compose down command will stop your containers, but it also removes the stopped containers as well as any networks that were created. You can take down 1 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. There’s other neat things you could with the down command. Run the docker-compose down --help command to learn more about them.
Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.
Comments
© 2022 Nick Janetakis
Follow @nickjanetakis Force stop service containers. $ docker compose kill [options] [SERVICE...]
Forces running containers to stop by sending a SIGKILL signal. Optionally the signal can be passed, for example: $ docker-compose kill -s SIGINT
Usage
Extended description
Options
Name, shorthand Default Description
--signal , -s SIGKILL SIGNAL to send to the container. Parent command
Command Description
docker compose Docker Compose
Forces running containers to stop by sending a SIGKILL signal. Optionally the
signal can be passed, for example:
docker-compose kill -s SIGINT
fig, composition, compose, docker, orchestration, cli, kill Stop services $ docker compose stop [SERVICE...]
Stops running containers without removing them. They can be started again with docker compose start.Usage
Extended description
Options
Name, shorthand Default Description
--timeout , -t 10 Specify a shutdown timeout in seconds Parent command
Command Description
docker compose Docker Compose
Stops running containers without removing them. They can be started again with
docker-compose start.