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)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up