Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Dockerize everything TopConf Tallinn

492 views

Published on

The hype around Docker is big, but does Docker live up to it? What is that this new tool excites developers and operators in unison? In this talk I will show what makes Docker different and what the vision behind it is. I will also give some practical insights from using Docker in development and production and demonstrate why I started to “dockerize" everything.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Dockerize everything TopConf Tallinn

  1. 1. Dockerize Everything Thomas Einwaller, troii Software @tompson
  2. 2. products
  3. 3. products technologies
  4. 4. 2008
  5. 5. 2008 2013
  6. 6. Number of Processes ~$ ps ax | wc -l 283 ~$ docker run ubuntu ps ax PID TTY STAT TIME COMMAND 1 ? Rs 0:00 ps ax
  7. 7. code runtime libraries OS container what is in a container?
  8. 8. image layers
  9. 9. ubuntu nginx java tomcat App A App B wordpress website X “inheritance”
  10. 10. one process per container tomcat mysql war, .properties link container A container B
  11. 11. immutable
  12. 12. ship the whole environment
  13. 13. DevOps
  14. 14. How to get started?
  15. 15. Docker Toolbox
  16. 16. Search and Run an Image ~$ docker search -s 10 wordpress NAME DESCRIPTION STARS OFFICIAL wordpress The WordPress rich content management syst... 323 [OK] tutum/wordpress Wordpress Docker image - listens in port 8... 40 ... ~$ docker run wordpress Unable to find image 'wordpress:latest' locally latest: Pulling from wordpress 60fa28093d2e: Pull complete a8f83d6d9aa9: Pull complete d0ca8f539db8: Pull complete ...
  17. 17. How to build my own?
  18. 18. Custom Container ~$ docker run -it ubuntu /bin/bash root:/# root:/# apt-get install -y mysql-server Reading package lists... Done Building dependency tree Reading state information... Done …
  19. 19. Commit Container ~$ docker ps CONTAINER ID IMAGE COMMAND NAMES e5a0e59fd3fd ubuntu:latest "/bin/bash" prickly_nobel ~$ docker commit prickly_nobel tom/mysql CONTAINER ID IMAGE COMMAND NAMES e5a0e59fd3fd ubuntu:latest "/bin/bash" prickly_nobel ~$ docker images REPOSITORY TAG IMAGE ID VIRTUAL SIZE tom/mysql latest 86a1fcd53530 512.1 MB ~$ docker run tom/mysql ...
  20. 20. Dockerfile FROM ubuntu MAINTAINER Thomas Einwaller, tom@troii.com RUN apt-get update && apt-get -y install apache2 ENV APACHE_RUN_USER www-data ENV APACHE_RUN_GROUP www-data ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2 ENV APACHE_PID_FILE /var/run/apache2.pid RUN mkdir /var/lock/apache2 EXPOSE 80 CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
  21. 21. Docker build ~$ docker build -t tom/apache2 . Sending build context to Docker daemon 2.048 kB Sending build context to Docker daemon Step 0 : FROM ubuntu ---> bdb87369f343 Step 1 : MAINTAINER Thomas Einwaller, tom@troii.com ---> Using cache ---> adcf06d4a78f Step 2 : RUN apt-get update && apt-get -y install apache2 ---> Using cache ---> 5aee61ee1c84 ... Step 9 : EXPOSE 80 ---> Using cache ---> ac985c02bfd6 Step 10 : CMD /usr/sbin/apache2 -D FOREGROUND ---> Running in 0a822e00e190 ---> 89ac6eef066c Successfully built 89ac6eef066c
  22. 22. Docker history ~$ docker history tom/apache2 IMAGE CREATED CREATED BY SIZE a6b064aec848 2 minutes ago /bin/sh -c #(nop) CMD ["/usr/sbin/apache2" "- 0 B dc0e02dc4d11 2 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0 B 1bc593d23431 2 minutes ago /bin/sh -c mkdir /var/lock/apache2 0 B afdda46774c6 2 minutes ago /bin/sh -c #(nop) ENV APACHE_PID_FILE=/var/ru 0 B 7f1a112bfd2e 2 minutes ago /bin/sh -c #(nop) ENV APACHE_LOCK_DIR=/var/lo 0 B 8a95fc52c646 2 minutes ago /bin/sh -c #(nop) ENV APACHE_LOG_DIR=/var/log 0 Ba32a610ccb8 2 minutes ago /bin/sh -c #(nop) ENV APACHE_RUN_GROUP=www-da 0 B 8083f7e42d6d 2 minutes ago /bin/sh -c #(nop) ENV APACHE_RUN_USER=www-dat 0 B 8cbd4df21d8b 2 minutes ago /bin/sh -c apt-get update && apt-get -y insta 30.63 MB ddfbce728239 2 minutes ago /bin/sh -c #(nop) MAINTAINER Thomas Einwaller 0 B bdb87369f343 5 weeks ago /bin/sh -c #(nop) CMD [/bin/zsh] 0 B ....
  23. 23. Docker push ~$ docker push tom/apache2 Sending image list Pushing repository tom/apache2 (1 tags) Image 511136ea3c5a already pushed, skipping Image 9fec74352904 already pushed, skipping Image d0955f21bf24 already pushed, skipping ...
  24. 24. Docker push ~$ docker push tom/apache2 Sending image list Pushing repository tom/apache2 (1 tags) Image 511136ea3c5a already pushed, skipping Image 9fec74352904 already pushed, skipping Image d0955f21bf24 already pushed, skipping ... and pull ~$ docker pull tom/apache2 Unable to find image 'tom/apache2:latest' locally latest: Pulling from tom/apache2 60fa28093d2e: Pull complete a8f83d6d9aa9: Pull complete d0ca8f539db8: Pull complete ...
  25. 25. How to use it?
  26. 26. git repository artifact repository Development Environment Continuous Integration Source Artifact (.war, .jar, ...) Test/Prod Environment build / deployment pipeline before docker
  27. 27. build / deployment pipeline with docker git repository artifact repository docker repository Development Environment Continuous Integration Source Artifact (.war, .jar, ...) Continuous Integration Test/Prod Environment Docker Image
  28. 28. Development Environment ~$ docker run -v /Users/tom/website:/website nginx … ~$ docker run -v /Users/tom/code:/code node …
  29. 29. or
  30. 30. Backup Tools ~$ docker run --volumes-from=nexus_data -e SOURCE=/usr/local/sonatype-work -e TARGET=s3://s3-eu-west-1.amazonaws.com/nexus-backup/ -e TARGET_USER=$AWSACCESSKEYID -e TARGET_PASS=$AWSSECRETACCESSKEY duply ~$ docker run --link mysql:db -e BUCKET_NAME=mysql-backup -e AWSACCESSKEYID=$AWSACCESSKEYID -e AWSSECRETACCESSKEY=$AWSSECRETACCESSKEY -e DBNAMES=test -e USERNAME=user -e PASSWORD=password automysqlbackup
  31. 31. Backup Tools ~$ docker run -v /home/tom/development/src:/src groovy //.gvm/groovy/ current/bin/groovy /src/script.groovy ~$
  32. 32. dexec
  33. 33. dexec
  34. 34. Docker machine ~$ docker-machine create --driver virtualbox dev INFO[0001] Downloading boot2docker.iso to /home/tom/.docker/machine/ INFO[0011] Creating SSH key... INFO[0012] Creating VirtualBox VM... INFO[0019] Starting VirtualBox VM... ... ~$ docker-machine ls NAME ACTIVE DRIVER STATE URL dev * virtualbox Running tcp://192.168.99.103:2376 staging digitalocean Running tcp://104.236.50.118:2376
  35. 35. Docker compose nginx: image: nginx:1.9.6 ports: - "80:80" links: - webapp webapp: build: . links: - db db: image: postgres
  36. 36. docker swarm
  37. 37. docker networking
  38. 38. https://github.com/docker/dockercraft
  39. 39. https://github.com/docker/dockercraft
  40. 40. conclusion • set up development environments (database, languages, …) • move packages to test environments (no more “works on my machine”) • move the SAME package to production (server, cloud …)
  41. 41. timr.com discount code ‘TOPCONF’ -20 % @tompson tom@troii.com

×