Docker Cheat Sheet
by notapatch via cheatography.com/69520/cs/17564/
Container Running Container Management Commands Management
Run a new container List containers What version
docker container run [options] IMAGE[:TAG] docker container ls docker version
[COMMAND]
docker ps old command Configuration values for the docker engine
Options
Create a container docker info
--rm remove container
docker container create [OPTIONS] List of all commands
on exit
IMAGE docker
--name add container ID
Remove a container
-e set environment
Networks
variable docker container rm
-p publish container -f force removal of running container List network
ports to host docker network ls
Remove all stopped containers
--network connect container Inspect network
docker container prune
to network
docker network inspect
--net-alias network scoped List processes in specific container
alias for the docker container top [container] Create a network
container docker network create [network]
Show logs on specific container
-d container in Attach a network to container
docker container logs [container]
background /
docker network connect [network]
detached List docker container commands
[container]
-it run interactively docker container
Detach a network from container
-v=[host- Volume
src:]container- Container commands docker network disconnect [network]
[container]
dest[:<options>] start a new container interactively
-v $(pwd):/app map the pwd into docker container run -it
Images
the '/app' folder
Run additional process in running container
Start an existing Container List images
docker container exec CONTAINER
docker container start [container] docker images [OPTIONS]
[CMD]
-a attach Re-tag an image
docker container exec -it
docker image tag SOURCE_IMAGE[:tag]
-i interactive my_alpine ping my_ubuntu
TARGET_IMAGE[:tag]
Stop a running container docker container run --rm --net
Log in to registry (the Docker Hub by default)
docker container stop [container] bcs alpine nslookup search
docker login
Kill a running container List of ports forwarding traffic from host to
container Push an image to the registry
docker container kill [container]
docker container port [container] docker push [options] NAME[:TAG]
Display detailed container information Pull an image
docker container inspect docker pull [options] NAME[:TAG]
Build an image from a Dockerfile
docker image build [OPTIONS] PATH
-t tag
By notapatch Not published yet. Sponsored by CrosswordCheats.com
cheatography.com/notapatch/ Last updated 25th October, 2018. Learn to solve cryptic crosswords!
Page 1 of 2. http://crosswordcheats.com
Docker Cheat Sheet
by notapatch via cheatography.com/69520/cs/17564/
Docker File - image recipies
Set the base image for further instructions
FROM <image>[:<tag>]
Set environment variables
ENV <key>=<value>
Set instruction to execute
RUN <command> [&& <command>]
Set the ports that the container listens on
EXPOSE <port> [<port>/<protocol>...]
Default command for executing container
CMD ["executable", "param1", "param2"]
Working directory changed for later instructions
WORKDIR /path/to/workdir
Copy files
COPY [--chown=<user>:<group>] <src>... <dest>
Docker Compose
Start system
docker-compose up
--build - rebuild container
-d detach/launch in background
Stop and Remove system
docker-compose down
List containers
docker-compose ps
Docker Volume
Where does the container keep the volume?
docker container inspect [options] CONTAINER
Detailed information on one or more volume
docker volume inspect [OPTIONS] VOLUME
List volumes
docker volume ls [OPTIONS]
Remove all unused local volumes
docker volume prune
By notapatch Not published yet. Sponsored by CrosswordCheats.com
cheatography.com/notapatch/ Last updated 25th October, 2018. Learn to solve cryptic crosswords!
Page 2 of 2. http://crosswordcheats.com