Skip to content

Instantly share code, notes, and snippets.

@schneefisch
Last active June 3, 2025 14:10
Show Gist options
  • Save schneefisch/bfcae96d0c164d0e6f897043e127e1a5 to your computer and use it in GitHub Desktop.
Save schneefisch/bfcae96d0c164d0e6f897043e127e1a5 to your computer and use it in GitHub Desktop.
Basic docker command line entries

This file contains basic commands for controlling docker

list running containers

docker ps

stop containers

docker stop <containerId>
docker kill <containerId>

remove stopped container

docker rm <container_id>
docker rmi <image_id>

remove unused data

docker system prune

ssh into a docker container

docker exec -it <container> /bin/bash

Delete all containers

docker rm $(docker ps -aq)

Delete all images

docker rmi $(docker images -q)

Delete all dangling images

docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

Force-Delete all images

docker rmi -f $(docker images -q)

cleanup docker containers

docker container stop $(docker container ls -a -q) && docker system prune --all --force --volumes

cleanup docker volumes

docker volume rm $(docker volume ls -q)

Add tag

docker tag docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

Upload

docker push TARGET_IMAGE[:TAG]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment