DEV Community

Cover image for Docker maintenance commands
Prabusah
Prabusah

Posted on • Edited on

1

Docker maintenance commands

Hello there!
Here are few Docker maintenance commands.

image commands
docker image ls - lists docker images.
docker images -aq -f 'dangling=true' | xargs docker rmi - removes all unused images.
docker rmi imageId - remove an image.
docker rmi -f imageId - force remove an image
docker rmi -f $(docker images -q) - deletes all images forcefully.

instance commands
docker ps - lists running docker instances.
docker ps -a - lists docker instances (including stopped).
docker stop containerId - stops the container (proper shutdown).
docker kill containerId - stops the container (not gracefully shutdown).
docker rm containerId - remove a stopped container.
docker rm $(docker ps -a -q) - removes all stopped containers.

execution commands
docker exec -it containerName /bin/bash - Use this to interact with already running container.
docker run -it --entrypoint=/bin/bash containerName - Starts the docker and lands user in shell.
docker logs -t containerName - shows logs even for container with exited status.

Image by Alexander Fox | PlaNet Fox from Pixabay

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay