Arnaud Porterie - Using Machine & Docker to develop & build Docker

28
Using Machine & Docker to develop & build Docker Arnaud Porterie - @icecrime - 2015-05-13 - Paris @D2SI

Transcript of Arnaud Porterie - Using Machine & Docker to develop & build Docker

Using Machine & Docker to develop & build Docker

Arnaud Porterie - @icecrime - 2015-05-13 - Paris @D2SI

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

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

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!

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Core maintainers

Maintainers Docker Inc.

Docker Inc. sponsored maintainers

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Core maintainers

Maintainers

Docker

Google

Microsoft

RedHatIBM

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Docker platform overview

Engine

SwarmMachine

Compose Kitemati

c

distribution

libcontainer

libnetwork

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Docker platform overview

Component GitHub Contributors Stats

Engine docker/docker 928

Compose docker/compose 86

Machine docker/machine 62

Swarm docker/swarm 64

Kitematic kitematic/kitematic 18

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

That being said…

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

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

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.

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Demo: using machine

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

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Demo: a peek at the source

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Docker’s Dockerfile• Yes, there’s a Dockerfile in the docker repo

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Docker’s Dockerfile

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Docker’s Dockerfile

• Describes the Docker development environment

• System dependencies

• Golang packages

• …

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Demo: docker build

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

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 .

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

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Demo: editing from the host

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

• …

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

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Demo: working with branches

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!

Arnaud Porterie - @icecrime - 2015-05-13 Docker Paris @D2SI

Thanks! Questions?