Skip to content

WSMathias/docker-cheat-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

docker-cheat-sheet

Best way to clean up Docker data safely:
docker system prune -a --volumes

Networks:


Remove all Networks:
docker network prune -f

or

docker network rm $(docker network ls | grep "bridge" | awk '/ / { print $1 }')

Volumes:


Remove all dangling volumes:
docker volume rm $(docker volume ls -qf dangling=true)

Images:


Remove only dangling images:
docker rmi $(docker images -f dangling=true -q)
Remove all images:
docker rmi $(docker images -f -a -q)
Remove images with pattern:
docker images -a | grep "pattern" | awk '{print $3}' | xargs docker rmi
List dockerfile commands
docker history --no-trunc <image>

Containers:


Remove all stopped containers:
docker rm $(docker ps -a -q)

or

docker container prune
Docker Run and remove (my-container) container when stopped:
docker run --rm -it my-docker 
Remove all containers forcefully:
docker rm --force $(docker ps -a -q)

or

docker container prune -f

Exec inside a container

docker exec -it <container_name|contianer_id> bash

Registry:


Acessing Registry (v2) with curl:

Note: for protected registry, basic auth argument username:password.

List repositories:

Docker registry is running in a local container.

curl -X GET http://localhost:5000/v2/_catalog
List tags from a repository:
curl -X GET http://localhost:5000/v2/<repository>/tags/list

Additional guides

Remote Docker setup (over TCP port)
Install Docker using snap
Installing dokcer-compose (linux)

Other Cheat Sheets

Git
SSH
Docker Compose

References

Releases

No releases published

Packages

No packages published