Skip to content

WSMathias/docker-cheat-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

docker-cheat-sheet

Best way to clean docker 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 container Forcefully:
docker rm --force $(docker ps -a -q)
# or
docker container prune -f

Registry:


Acessing Registry (v2) with curl:

Note: for protected registry basic auth argument-u username:password.

List reporistories:

docker registry ins running in 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