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

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

Aug 04, 2015

Download

Technology

icecrime
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Arnaud Porterie - Using Machine & Docker to develop & build Docker

Using Machine & Docker to develop & build Docker

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

Page 2: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 3: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 4: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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!

Page 5: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Core maintainers

Maintainers Docker Inc.

Docker Inc. sponsored maintainers

Page 6: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Core maintainers

Maintainers

Docker

Google

Microsoft

RedHatIBM

Page 7: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Docker platform overview

Engine

SwarmMachine

Compose Kitemati

c

distribution

libcontainer

libnetwork

Page 8: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 9: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

That being said…

Page 10: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 11: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 12: Arnaud Porterie - Using Machine & Docker to develop & build 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.

Page 13: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Demo: using machine

Page 14: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 15: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Demo: a peek at the source

Page 16: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

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

Page 17: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Docker’s Dockerfile

Page 18: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Docker’s Dockerfile

• Describes the Docker development environment

• System dependencies

• Golang packages

• …

Page 19: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Demo: docker build

Page 20: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 21: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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 .

Page 22: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 23: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Demo: editing from the host

Page 24: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

• …

Page 25: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Page 26: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Demo: working with branches

Page 27: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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!

Page 28: Arnaud Porterie - Using Machine & Docker to develop & build Docker

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

Thanks! Questions?