Download - Dockerize everything TopConf Tallinn
![Page 1: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/1.jpg)
Dockerize EverythingThomas Einwaller, troii Software
@tompson
![Page 2: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/2.jpg)
![Page 3: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/3.jpg)
products
![Page 4: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/4.jpg)
products technologies
![Page 5: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/5.jpg)
![Page 6: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/6.jpg)
2008
![Page 7: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/7.jpg)
2008
2013
![Page 8: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/8.jpg)
![Page 9: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/9.jpg)
![Page 10: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/10.jpg)
![Page 11: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/11.jpg)
![Page 12: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/12.jpg)
![Page 13: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/13.jpg)
![Page 14: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/14.jpg)
Number of Processes
~$ ps ax | wc -l 283
~$ docker run ubuntu ps axPID TTY STAT TIME COMMAND 1 ? Rs 0:00 ps ax
![Page 15: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/15.jpg)
![Page 16: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/16.jpg)
code
runtime
libraries
OS
container
what is in a container?
![Page 17: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/17.jpg)
image layers
![Page 18: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/18.jpg)
ubuntu
nginx java
tomcat
App A App B
wordpress website X
“inheritance”
![Page 19: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/19.jpg)
one process per container
tomcat mysql
war, .properties
link
container A container B
![Page 20: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/20.jpg)
immutable
![Page 21: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/21.jpg)
ship the whole environment
![Page 22: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/22.jpg)
DevOps
![Page 23: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/23.jpg)
How to get started?
![Page 24: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/24.jpg)
Docker Toolbox
![Page 25: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/25.jpg)
![Page 26: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/26.jpg)
![Page 27: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/27.jpg)
![Page 28: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/28.jpg)
Search and Run an Image
~$ docker search -s 10 wordpress NAME DESCRIPTION STARS OFFICIALwordpress The WordPress rich content management syst... 323 [OK]tutum/wordpress Wordpress Docker image - listens in port 8... 40 ...
~$ docker run wordpressUnable to find image 'wordpress:latest' locallylatest: Pulling from wordpress60fa28093d2e: Pull completea8f83d6d9aa9: Pull completed0ca8f539db8: Pull complete...
![Page 29: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/29.jpg)
How to build my own?
![Page 30: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/30.jpg)
Custom Container
~$ docker run -it ubuntu /bin/bashroot:/#
root:/# apt-get install -y mysql-serverReading package lists... DoneBuilding dependency treeReading state information... Done…
![Page 31: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/31.jpg)
Commit Container
~$ docker psCONTAINER ID IMAGE COMMAND NAMESe5a0e59fd3fd ubuntu:latest "/bin/bash" prickly_nobel
~$ docker commit prickly_nobel tom/mysqlCONTAINER ID IMAGE COMMAND NAMESe5a0e59fd3fd ubuntu:latest "/bin/bash" prickly_nobel
~$ docker images REPOSITORY TAG IMAGE ID VIRTUAL SIZEtom/mysql latest 86a1fcd53530 512.1 MB
~$ docker run tom/mysql ...
![Page 32: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/32.jpg)
Dockerfile
FROM ubuntuMAINTAINER Thomas Einwaller, [email protected]
RUN apt-get update && apt-get -y install apache2
ENV APACHE_RUN_USER www-dataENV APACHE_RUN_GROUP www-dataENV APACHE_LOG_DIR /var/log/apache2ENV APACHE_LOCK_DIR /var/lock/apache2ENV APACHE_PID_FILE /var/run/apache2.pidRUN mkdir /var/lock/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
![Page 33: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/33.jpg)
Docker build
~$ docker build -t tom/apache2 .Sending build context to Docker daemon 2.048 kBSending build context to Docker daemonStep 0 : FROM ubuntu ---> bdb87369f343Step 1 : MAINTAINER Thomas Einwaller, [email protected] ---> Using cache ---> adcf06d4a78fStep 2 : RUN apt-get update && apt-get -y install apache2 ---> Using cache ---> 5aee61ee1c84...Step 9 : EXPOSE 80 ---> Using cache ---> ac985c02bfd6Step 10 : CMD /usr/sbin/apache2 -D FOREGROUND ---> Running in 0a822e00e190 ---> 89ac6eef066cSuccessfully built 89ac6eef066c
![Page 34: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/34.jpg)
Docker history
~$ docker history tom/apache2IMAGE CREATED CREATED BY SIZEa6b064aec848 2 minutes ago /bin/sh -c #(nop) CMD ["/usr/sbin/apache2" "- 0 Bdc0e02dc4d11 2 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0 B1bc593d23431 2 minutes ago /bin/sh -c mkdir /var/lock/apache2 0 Bafdda46774c6 2 minutes ago /bin/sh -c #(nop) ENV APACHE_PID_FILE=/var/ru 0 B7f1a112bfd2e 2 minutes ago /bin/sh -c #(nop) ENV APACHE_LOCK_DIR=/var/lo 0 B8a95fc52c646 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 B8083f7e42d6d 2 minutes ago /bin/sh -c #(nop) ENV APACHE_RUN_USER=www-dat 0 B8cbd4df21d8b 2 minutes ago /bin/sh -c apt-get update && apt-get -y insta 30.63 MBddfbce728239 2 minutes ago /bin/sh -c #(nop) MAINTAINER Thomas Einwaller 0 Bbdb87369f343 5 weeks ago /bin/sh -c #(nop) CMD [/bin/zsh] 0 B....
![Page 35: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/35.jpg)
![Page 36: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/36.jpg)
Docker push
~$ docker push tom/apache2Sending image listPushing repository tom/apache2 (1 tags)Image 511136ea3c5a already pushed, skippingImage 9fec74352904 already pushed, skippingImage d0955f21bf24 already pushed, skipping...
![Page 37: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/37.jpg)
Docker push
~$ docker push tom/apache2Sending image listPushing repository tom/apache2 (1 tags)Image 511136ea3c5a already pushed, skippingImage 9fec74352904 already pushed, skippingImage d0955f21bf24 already pushed, skipping...
and pull
~$ docker pull tom/apache2Unable to find image 'tom/apache2:latest' locallylatest: Pulling from tom/apache260fa28093d2e: Pull completea8f83d6d9aa9: Pull completed0ca8f539db8: Pull complete...
![Page 38: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/38.jpg)
How to use it?
![Page 39: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/39.jpg)
gitrepository
artifactrepository
DevelopmentEnvironment
Continuous Integration
SourceArtifact
(.war, .jar, ...)
Test/ProdEnvironment
build / deployment pipeline before docker
![Page 40: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/40.jpg)
build / deployment pipeline with docker
gitrepository
artifactrepository
dockerrepository
DevelopmentEnvironment
Continuous Integration
SourceArtifact
(.war, .jar, ...)
Continuous Integration
Test/ProdEnvironment
DockerImage
![Page 41: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/41.jpg)
Development Environment
~$ docker run -v /Users/tom/website:/website nginx…
~$ docker run -v /Users/tom/code:/code node…
![Page 42: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/42.jpg)
or
![Page 43: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/43.jpg)
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
![Page 44: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/44.jpg)
Backup Tools
~$ docker run -v /home/tom/development/src:/src groovy //.gvm/groovy/current/bin/groovy /src/script.groovy
~$
![Page 45: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/45.jpg)
dexec
![Page 46: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/46.jpg)
dexec
![Page 47: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/47.jpg)
Docker machine
~$ docker-machine create --driver virtualbox devINFO[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 lsNAME ACTIVE DRIVER STATE URLdev * virtualbox Running tcp://192.168.99.103:2376staging digitalocean Running tcp://104.236.50.118:2376
![Page 48: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/48.jpg)
Docker compose
nginx:image: nginx:1.9.6
ports: - "80:80" links: - webappwebapp: build: . links: - dbdb: image: postgres
![Page 49: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/49.jpg)
docker swarm
![Page 50: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/50.jpg)
docker networking
![Page 51: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/51.jpg)
![Page 52: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/52.jpg)
https://github.com/docker/dockercraft
![Page 53: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/53.jpg)
https://github.com/docker/dockercraft
![Page 54: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/54.jpg)
![Page 55: Dockerize everything TopConf Tallinn](https://reader031.vdocument.in/reader031/viewer/2022021922/58a114631a28ab4b658b62bd/html5/thumbnails/55.jpg)
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 …)