Skip to content

Instantly share code, notes, and snippets.

@NileshPatel17
Last active October 1, 2021 08:07
Show Gist options
  • Save NileshPatel17/e03a72d8689bab4b2d015f6c7753f6eb to your computer and use it in GitHub Desktop.
Save NileshPatel17/e03a72d8689bab4b2d015f6c7753f6eb to your computer and use it in GitHub Desktop.
useful-docker-commands.md

Docker commands:

kill all running containers

docker kill $(docker ps -q)

delete all stopped containers

docker rm $(docker ps -a -q)

delete all images

docker rmi $(docker images -q)

update and stop a container that is in a crash-loop

docker update --restart=no && docker stop

bash shell into container (if bash is not available use /bin/sh)

docker exec -i -t /bin/bash

bash shell with root if container is running in a different user context

docker exec -i -t -u root /bin/bash

delete all containers including its volumes use

docker rm -vf $(docker ps -a -q)

Remove all unused containers, volumes, networks and images

docker system prune -a --volumes

view container log

docker logs -f 49725ba5da0f

-f, --follow Follow log output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment