Docker cheat sheet
We describe here the most common Docker usage
Alternate links
The ultimate Docker cheat sheet
Commands detail
Tip
To have details on a particular command
docker <command> --help
Build
Build an image from the Dockerfile in the current directory and tag the image
docker build -t myimage:1.0 .
docker image ls
docker image rm alpine:3.4
Share
Pull an image from a registry
docker pull myimage:1.0
docker tag myimage:1.0 myrepo/myimage:2.0
Push an image to a registry
docker push myrepo/myimage:2.0
Run
Run a container from the Alpine version 3.9 image, name the running container “web” and expose port 5000 externally, mapped to port 80 inside the container.
docker container run --name web -p 5000:80 alpine:3.9
docker container stop web
docker container kill web
docker network ls
List the running containers (add --all to include stopped containers)
docker container ls
docker container rm -f $(docker ps -aq)
docker container logs --tail 100 web