With release 1.13, Docker has greatly simplified interacting with the various assets docker containers use to run. These components include containers, networks, volumes, and images.
-
List all images:
docker image ls -a -
List all containers:
docker container ls -a -
Stop all containers:
docker container stop $(docker container ls -aq) -
Remove all stopped containers:
docker container rm -v $(docker container ls -aq) -
Pull new images:
docker pull <container>:<version>(default version is:latest) -
Remove dangling images (do this after pulling new versions, so that you keep your images clean):
docker image rm $(docker image ls -f "dangling=true" -q) -
To clean up your system completely (remove all orphaned containers, networks, volumes):
docker system prune -
To ssh into container:
docker exec -it /bin/bash
To use docker CLI, select an asset from container, image, volume, or network, then a command to execute, then the ID or list of IDs of the assets you would like to interact with. Syntax is of form:
docker <asset> <command> <id> <options>