Docker is used to run applications in isolated containers. Key concepts include images which are read-only templates for containers, containers which are runnable instances of images, and registries where public images are stored. Docker commands allow users to download images, run containers from images specifying ports and volumes, manage container lifecycles, and commit running containers to new images. Docker Compose allows defining and running multi-container applications with a single configuration file.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
266 views1 page
ZT Docker Cheat Sheet
Docker is used to run applications in isolated containers. Key concepts include images which are read-only templates for containers, containers which are runnable instances of images, and registries where public images are stored. Docker commands allow users to download images, run containers from images specifying ports and volumes, manage container lifecycles, and commit running containers to new images. Docker Compose allows defining and running multi-container applications with a single configuration file.
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