Skip to content

Instantly share code, notes, and snippets.

@Adron
Last active April 26, 2021 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adron/ad1b2a05ea7979dca466e881ade584bd to your computer and use it in GitHub Desktop.
Save Adron/ad1b2a05ea7979dca466e881ade584bd to your computer and use it in GitHub Desktop.
Docker Commands : Killing/Stopping/Removing Containers and Images
# Stopping a single container that is running.
docker stop 0bd1f4ccb52d
# Stopping two or more containers that are running.
docker stop 0bd1f4ccb52d 0bd1f4ccb52d
# Showing a list of all containers.
docker ps -a
# Showing a list of the container IDs that are actively running.
docker ps -q
# Showing a list of the container IDs for those that are stopped and actively running.
docker ps -aq
# Stopping all the containers returned from the list of IDs, which in this case is all of the actively running containers.
docker stop $(docker ps -q)
# Cleanup the volumes that any the database or related images/containers may have left behind.
docker volune prune
# Removing the containers that are actively running and stopped.
docker rm $(docker ps -aq)
# Removing all of the container images by their respective ID.
docker rmi $(docker images -q)
# Tweak to force remove all images.
docker rmi $(docker images -q) -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment