Docker Command Line Cheatsheet Notes
A list of Docker and Docker-related commands.
More to come! I’m adding as I find a need.
Delete the last run Docker Container:
docker ps -l -q | xargs docker rm -v
Delete all Docker Containers:
docker ps -a -q | xargs docker rm -v
Delete all Docker Volumes:
docker volume ls -q | xargs docker volume rm
Delete all unnamed Docker Images:
docker images | grep "<none>" | tr -s ' ' | cut -d' ' -f 3 | xargs docker rmi
Connect a local pipe to a running Docker container:
echo test | docker exec -i container_name cat
Update all externally hosted images, ignoring errors:
docker images --format "{{.Repository}}:{{.Tag}}" | xargs -n1 bash -c 'echo $0;docker pull $0 || true'
List all containers by Name
docker inspect --format='{{.Name}}' $(docker ps -aq)
Inspect every container:
for CONTAINER in `docker inspect $(docker ps -q)`; do docker inspect $CONTAINER > inspect-`basename $CONTAINER`.txt; done