A brief introduction

Thach MAI, full stack dev: www.thachmai.info.
Introduction to Docker: optimise for the big picture rather than the specifics.
All examples require only Docker + internet.

Container vs VM

VM simulates a complete computer: OS, lots of hardware options.
Container runs in the same OS as the host as an isolated process (Linux kernel only).
Container has much less things to manage, with a uniform admin console.

What is a container?

- Streams: stdin and stdout.
- Network: IP and ports.
- File system: directories and files.

Running a container

docker run hello-world
- How does Docker find the hello-world container? Machine local cache, then a registry (private or Docker Hub).
- A running container has a name + hash.

stdin & stdout (1)

docker run hello-world
- stdout is your terminal stdout.
- stdin is not connected.

stdin & stdout (2)

docker run -d hello-world
- stdout is directed to a log.
- Run docker ps -a to show the list of containers.
- Run docker logs <name> to see the output.

stdin & stdout (3)

docker run -it ubuntu
- stdout is your terminal stdout.
- stdin is your terminal stdin.

Network Mapping

docker run -p 27017:27017 -d mongo
- This command maps the host's port 27017 to the container's port 27017.
- Now you can connect to the container with mongo localhost:27017.

Union File System (1)

- An onion-like file system: layers.
- Starts with a core: an base image.
- Outer layers hide inner layers.
- Each layer is immutable and identified by its hash (just like git).

Union File System (2)

- To recompose a container image, you just need to retrieve all of its layers.
- Docker Hub is simply an online host of these layers + admin stuff.

Union File System (3)

- When you're running a container, its file system is updated.
- These changes are stored in an outer layer that persists on your host.
- Docker doesn't delete the layers automatically when container stops.
- Use volume mapping if you want to easily extract data from container.
docker run -d -p 27017:27017 -v /data/db:/data/db mongo

How is Docker today?

- Container is an awesome idea that will change how we think about software deployment.
- Is Docker production ready at version 1.7? I'm not sure.
  * Lots of bugs, slow turn-around.
  * Security issues.
  * Emphasis seems to be on new toys (Compose, Swarm) than stabilization.
- If Docker doesn't work out, CoreOS or someone else will.

My strategy for adoption

- My personal strategy, I hope to hear yours.
- Get ready for containers, but don't commit all-in with Docker yet.
- Using Docker in production right now can significantly simplify your deployment process, but some (or a lot) of pain can be expected.