jingyi's blog

Little Docker Tips

Change entrypoint on the fly

source

docker run -it --entrypoint=/bin/bash <image_name>

Reveal the full command of a container

source

docker inspect  -f "{{.Name}} {{.Config.Cmd}}" $(docker ps -a -q)

BTW, docker ps -a -q only prints container ID, which is better than docker ps -a | awk '{print $1}'.

Clean up dead containers

source

docker rm $(docker ps --all -q -f status=dead)

Free Docker space

source

# clean up images
docker rmi $(docker images -a --filter=dangling=true -q)
# clean up ps
docker rm $(docker ps --filter=status=exited --filter=status=created -q)

Note that with -q, docker ps only print CONTAINER ID

List the layers of adocker image

docker inspect <img> | jq .[].RootFS.Layers
# OR 
docker history <img>

#Docker