docker at monoco.jp (linkedin)

20

Upload: akhmad-fathonih

Post on 17-Aug-2015

37 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Docker at Monoco.jp (LinkedIn)
Page 2: Docker at Monoco.jp (LinkedIn)

Life before Docker

Take notes of what you install and uninstall on the server

Page 3: Docker at Monoco.jp (LinkedIn)

Life before Docker

Pass along the installation note when someone want to copy the setting

Page 4: Docker at Monoco.jp (LinkedIn)

Life Before Docker

➔ Why the installation note does not work on their laptop/server? It’s their fault!

➔ Production server busted? Go back to installation note.

Page 5: Docker at Monoco.jp (LinkedIn)

VM?

➔ How can you move it to production? Without rebuilding the image?

➔ Can you run multiple instance using the same image? Without duplicating?

➔ Shit, I just broke the image. Can we use the previous version? No rebuilding?

➔ Can we make it slim? Like just 200MB for nginx stack?

Page 6: Docker at Monoco.jp (LinkedIn)

“an open-source project that automates

the deployment of applications inside

software containers, by providing an

additional layer of abstraction and

automation of operating system–level

virtualization on Linux.”

Docker is

Page 7: Docker at Monoco.jp (LinkedIn)

Share more resource with host✓ Lightweight

Ship the image anywhere (Linux ;)✓ Portable

Tag the image for archiving✓ Versioning friendly

Build on top other✓ Stackable

Page 8: Docker at Monoco.jp (LinkedIn)

ASCII Demo

https://asciinema.org/a/14255

Page 9: Docker at Monoco.jp (LinkedIn)

Dockerfile

FROM nginx

$ docker build -t rtl-nginx .

$ docker run -d -p 80:80 rtl-nginx

$ open http://172.16.42.43

Page 10: Docker at Monoco.jp (LinkedIn)

Dockerfile #2

FROM nginxADD html /usr/share/nginx/html

$ docker build -t rtl-nginx-2 .

$ docker kill <pid>

$ docker run -d -p 80:80 rtl-nginx-2

$ open http://172.16.42.43

Page 11: Docker at Monoco.jp (LinkedIn)

Dockerfile #3

FROM nginx# stale content bug on Nginx x Vagrant x Mac OSX

RUN sed -i -e "s/sendfile.*/sendfile off;/g" /etc/nginx/nginx.conf

$ docker run -d -p 80:80 -v htdocs/RTL/nginx/html:/usr/share/nginx/html rtl-nginx

$ open http://172.16.42.43

Page 12: Docker at Monoco.jp (LinkedIn)

Docker implementation

1. Base imagea. Start with minimal stackb. Mimic production as much as you canc. Leave third party service alone

2. Dev imagea. Add build-toolsb. Add testing-tools: selenium, vnc

3. Deployable-imagea. Add third party services: newrelic, etcb. Finalize config

Page 13: Docker at Monoco.jp (LinkedIn)

Dev Workflow

➔ Setup◆ Virtual Box + Vagrant◆ boot2docker◆ docker-osx (directory mapping reason), alt

boot2docker

➔ Checkout dev image

➔ Mess with code

➔ Run tests

➔ Commit and push

Page 14: Docker at Monoco.jp (LinkedIn)

Continuous Integration cont.

➔ Devs push code

➔ Jenkins runs tests

➔ Not OK?◆ Complain in Hipchat

➔ All OK? ◆ Build deployable-image

◆ Push image into private registry

◆ Notify devs on Hipchat

Page 15: Docker at Monoco.jp (LinkedIn)

Staging

➔ Jenkins runs tests on trunk

➔ Build staging image

➔ Push staging image to private registry

➔ Tell Ansible to reload staging

Page 16: Docker at Monoco.jp (LinkedIn)

Staging Env

Page 17: Docker at Monoco.jp (LinkedIn)

Staging Env cont.

➔ using Fig (http://fig.sh)➔ Images:

◆ web apps◆ reverse-proxy (

https://github.com/jwilder/nginx-proxy)

➔ Flow (via Ansible)◆ pull latest image◆ restart web app instance◆ reverse-proxy reloads itself

Page 18: Docker at Monoco.jp (LinkedIn)

Production Env

➔ Elastic Beanstalk◆ using .ebextensions scripts to setup EC2

instance

◆ Newrelic for server monitoring

◆ Splunk for logging

➔ Manual deployment◆ i-am-not-so-sure environment

◆ fvck-it-ship-it enviroment

Page 19: Docker at Monoco.jp (LinkedIn)

Next, The Holy Grail

12 Factors App http://12factor.net

➔ Disposability (stateless)◆ started or stopped at a moment’s notice

➔ Config (via ENV vars)◆ app’s config varies between dev, staging, production

➔ Every setup is different. YMMV.

Page 20: Docker at Monoco.jp (LinkedIn)

docker.com/tryitlinkedin.com/in/neofreko

[email protected]@neofreko