docker at monoco.jp (linkedin)
TRANSCRIPT
Life before Docker
Take notes of what you install and uninstall on the server
Life before Docker
Pass along the installation note when someone want to copy the setting
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.
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?
“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
Share more resource with host✓ Lightweight
Ship the image anywhere (Linux ;)✓ Portable
Tag the image for archiving✓ Versioning friendly
Build on top other✓ Stackable
ASCII Demo
https://asciinema.org/a/14255
Dockerfile
FROM nginx
$ docker build -t rtl-nginx .
$ docker run -d -p 80:80 rtl-nginx
$ open http://172.16.42.43
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
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
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
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
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
Staging
➔ Jenkins runs tests on trunk
➔ Build staging image
➔ Push staging image to private registry
➔ Tell Ansible to reload staging
Staging Env
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
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
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.
docker.com/tryitlinkedin.com/in/neofreko
[email protected]@neofreko