Arnaud Porterie - Using Machine & Docker to develop & build Docker
1. Using Machine & Docker to
develop & build Docker
Arnaud Porterie - @icecrime - 2015-05-13 - Paris @D2SI
2. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Who am I?
• Arnaud Porterie
• @icecrime on and
• Joined Docker in Nov 2014 (previously in Paris)
• Project org: core maintainer
• Company org: engineering manager for Engine
3. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Who am I?
• Arnaud Porterie
• @icecrime on and
• Joined Docker in Nov 2014 (previously in Paris)
• Project org: core maintainer
• Company org: engineering manager for Engine
4. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Core maintainers
• Have write-access to the repo
• Are able to “LGTM”
• Review the 100+ PR we receive each week
• Don’t get to commit directly to master neither!
5. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Core maintainers
Maintainers Docker Inc.
Docker Inc.
sponsored maintainers
6. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Core maintainers
Maintainers
Docker
Google
Microsoft
RedHatIBM
…
7. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Docker platform overview
Engine
Sw
arm
M
achine
C
om
pose
K
item
atic
distribution
libcontainer
libnetwork
9. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
That being said…
10. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
What do we want to do?
• Start from a “clean” Mac (with docker client, git, …)
• Set up a development Linux VM
• Get and build the docker/docker repository
• See how we use Docker all along the way
11. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Setting up a Linux host
• Today, the Docker daemon is Linux only
• The client runs natively on OSX and Windows
• The daemon is being ported to Windows Server
• We need a Linux with Docker to develop on Docker
12. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Introducing Machine
• The easiest way to provision a Linux host with
Docker installed
• https://github.com/docker/machine
Machine lets you create Docker hosts on your computer, on
cloud providers, and inside your own data center. It creates
servers, installs Docker on them, then configures the Docker
client to talk to them.
13. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Demo: using machine
14. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Docker Engine source tree
• Client and daemon are the same binary
• Dependencies are vendored
• Commodity Makefile
$ git clone https://github.com/docker/docker
15. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Demo: a peek at the source
16. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Docker’s Dockerfile
• Yes, there’s a Dockerfile in the docker repo
20. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Why it matters
• From 0 to a working dev env in minutes
• No need to know versions of Go & dependencies
• No need to install anything on my host
• Consistency across all developers
• Also it’s Docker, so it can do everything Docker can
21. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
If I already have a Dockerfile
• Don’t mix deployment image with dev image
• Dev dependencies != runtime dependencies
• You can have multiple Dockerfiles since 1.5.0
$ ls Dockerfile*
Dockerfile Dockerfile.dev
$ docker build -f Dockerfile.dev -t dev .
22. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Development flow
• Sources are baked in the image
• Need to rebuild every time something changes
• Alternative: rely on bind mounts
• On Mac /Users/ happens to be shared by default
# Upload docker source
COPY . /go/src/github.com/docker/docker
23. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Demo: editing from the host
24. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Parallelizing work
• When your dev env is a Docker image, it’s easy to
spawn many of them
• For different projects
• For different branches
• On different hosts
• …
25. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Example: working with branches
• Build an image per branch
• Run a container for each
• Rely on docker attach and ^P^Q
26. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Demo: working with branches
27. Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI
Key points
• A new dev is operational in minutes
• It’s “just” a Docker image: different dev will choose
to run it differently, and on different hosts
• It’s “just” containers: spawn as many as needed
• What works for Docker can probably work for you!