A blog by Devendra Tewari
Interactively run command in a new container based on a Docker image
docker run -it -v `pwd`:/workdir -w /workdir 90e5ddae9277 /bin/bash
You can specify an image id, name, or name:tag. Image is downloaded from a configured registry, if needed. The current directory on the host is mapped to /workdir
in the container. /bin/bash
is started in that directory.
List running containers
docker ps
List all containers, and their sizes
docker ps -a -s
Start a stopped container, with terminal access
docker start -a -i 2edf9d536e3c
Execute a command in a running container—command in example below lists all network interfaces on Linux containers
docker exec -it container ip addr show
Remove a container
docker rm 2edf9d536e3c
Build an image using Dockerfile in the current folder
docker build .
Save Docker image
docker save -o myimage.tar 90e5ddae9277
Load Docker image from an input archive
docker load -i myimage.tar
List Docker images
docker image ls
Remove a Docker image
docker image rm 90e5ddae9277
See image history in human readable format—useful for identifying all the layers in an image
docker history -H 90e5ddae9277