What is Docker?
Is it a Virtual Machine? (No, docker uses the host kernel.)
Docker is a fancy way to run a process in isolation.
Container vs. Image
An image is what docker runs to create a container. You either pull an image from docker hub, or you build an image from a Dockerfile. (Think makefile)
What's a container?
Ok, in a linux server, you have many services, right? (nginx, mysql, redis, etc.) Ok, in docker these each would be a container.
Docker compose allows you to take a group of containers and stitch them together to make something. Example would be something like wordpress, where you connect nginx, php-fpm, and mysql.
version: "2" services: apache: image: nginx:alpine volumes: - ./wordpress:/usr/share/nginx/html ports: - "80:80" php: image: php:7-fpm volumes: - ./wordpress:/usr/share/nginx/html database: image: mysql:5 volumes: - ./data:/var/lib/mysql
Volumes are used to store persistent data.
Note: The ./wordpress directory is shared with nginx.
- What is Docker? How does it work?
- Images vs. Containers
- Building Images, Dockerfiles
Thank you nschoe for the great write-ups explaining the magic behind Docker.