You are on page 1of 1

Cheat Sheet

Glossary Useful one-liners Docker cleanup commands Docker compose syntax


Layer - a set of read-only files Download an image Kill all running containers docker-compose.yml file example
to provision the system docker pull image_name docker kill $(docker ps -q) version: 2
services:
Image - a read-only layer that Start and stop the container Delete dangling images web:
is the base of your container. docker [start|stop] container_name docker rmi $(docker images -q -f container_name: web
Might have a parent image dangling=true) image: java:8 # image name
Create and start container, run command # command to run
Container - a runnable instance docker run -ti --name container_name Remove all stopped containers command: java -jar /app/app.jar
of the image image_name command docker rm $(docker ps -a -q) ports: # map ports to the host
- 4567:4567
Registry / Hub - central place Create and start container, run command, volumes: # map filesystem to the host
where images live destroy container Docker machine commands - ./myapp.jar:/app/app.jar
docker run --rm -ti image_name command Use docker-machine to run the containers mongo: # container name
Docker machine - a VM to run image: mongo # image name
Docker containers (Linux does Example filesystem and port mappings Start a machine
this natively) docker run -it --rm -p 8080:8080 -v docker-machine start machine_name Create and start containers
/path/to/agent.jar:/agent.jar -e docker-compose up
Docker compose - a utility to run JAVA_OPTS=-javaagent:/agent.jar Configure docker to use a specific machine
multiple containers as a system tomcat:8.0.29-jre8 eval $(docker-machine env machine_name) Interacting with a container
Run a command in the container
docker exec -ti container_name command.sh

Container: my-container docker start my-container docker logs -ft my-container


Follow the container logs
docker logs -ft container_name

Image: tomcat:8.0.29-jre8 Processes Logs Save a running container as an image


docker commit -m commit message -a author
Parent image: java:8-jre java -jar tomcat.jar container_name username/image_name:tag

Parent image: buildpack-deps:jessie-curl


command.sh

Note: this container might run inside docker-machine

docker exec -ti my-container command.sh