hide your development environment and application in a container
TRANSCRIPT
![Page 1: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/1.jpg)
Hide your Development Environment and Application in a
ContainerBart Caro, Info Support
Johan Janssen, Info Support, @johanjanssen42
![Page 2: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/2.jpg)
Content Why Docker Different options Multiple teams Docker registry Summary Questions
![Page 3: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/3.jpg)
![Page 4: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/4.jpg)
![Page 5: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/5.jpg)
![Page 6: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/6.jpg)
![Page 7: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/7.jpg)
![Page 8: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/8.jpg)
Docker
![Page 9: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/9.jpg)
Transportation solution
![Page 10: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/10.jpg)
Docker compatibility
![Page 11: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/11.jpg)
My first Docker container
Docker on Ubuntu 15.04
apt-get install docker.io
docker run -it ubuntu:15.04 /bin/bash
![Page 12: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/12.jpg)
DockerfileFROM java:8-jdk
RUN wget …/netbeans-8.0.2-linux.shRUN chmod +x netbeans*.shRUN sh netbeans*.sh --silent
CMD /usr/local/netbeans-8.0.2/bin/netbeans
![Page 13: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/13.jpg)
Docker overview
![Page 14: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/14.jpg)
Updating containers
![Page 15: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/15.jpg)
Pull update only on Docker client 2docker images -tree└─153bf43b408a 194.2 MB test-version-0.1:latest
docker pull 192.168.56.31:5000/test-version-0.2 ff7e110ebadd: Download complete153bf43b408a: Download complete
docker images -tree└─153bf43b408a 194.2 MB test-version-0.1:latest └─ff7e110ebadd 194.2 MB test-version-0.2:latest
![Page 16: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/16.jpg)
Docker vs Virtual Machines
![Page 17: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/17.jpg)
Docker vs Virtual Machines Disk space efficiency Memory efficiency Speed Compatibility (run anywhere) Isolation Versioning Internet of Things (Raspberry Pi etc.)
![Page 18: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/18.jpg)
We need lots of Docker containersGeneralBase
AppServerBase
Environment D
Environment T
Environment A
Environment P
Jenkins
JenkinsDataContainer
Sonar Gitblit Nexus
![Page 19: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/19.jpg)
Diskspace# docker.io images --tree└─ 179.9 MB Tags: ubuntu:saucy └─253.6 MB └─741.8 MB Tags: GeneralBase:latest └─763.6 MB Tags: AppServerBase:latest
├─763.6 MB Tags: EnvironmentP:latest └─865.6 MB Tags: Nexus:latest └─808.3 MB Tags: Gitblit:latest └─901.5 MB Tags: Sonar:latest └─805.4 MB Tags: Jenkins:latest
![Page 20: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/20.jpg)
Execution time on laptop
real 4m11.729suser 0m3.329s sys 0m10.054s
![Page 21: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/21.jpg)
Docker usecases DTAP environment
Mainly running non-GUI applications
Continuous delivery, testing etc.
Development !
![Page 22: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/22.jpg)
![Page 23: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/23.jpg)
Persisting data on host
Docker run command: -v $PWD/workspace:/workspace
![Page 24: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/24.jpg)
What to persist? Workspace Plugins Application in application server Maven repo Configuration Entire home folder??
![Page 25: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/25.jpg)
Different options
![Page 26: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/26.jpg)
![Page 27: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/27.jpg)
X11
![Page 28: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/28.jpg)
Security Simple
Expose xhost Read / write through the X11 unix socket
Safer Use your user’s credentials to access the display
server Isolated
Create a user with the same uid and gid as the host SSH More info:
http://wiki.ros.org/docker/Tutorials/GUI
![Page 29: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/29.jpg)
No protocol specified error
No protocol specified error ->xhost local:root
![Page 30: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/30.jpg)
General part DockerfileRUN wget …/netbeans-8.0.2-linux.shRUN chmod +x netbeans*.shRUN sh netbeans*.sh –silent// Set netbeans_default_userdir=/workspace/userdir RUN sed -i …// Set netbeans_default_cachedir=/workspace/cachedirRUN sed -i …
![Page 31: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/31.jpg)
X11 DockerfileFROM java:8-jdk
// General part
CMD /usr/local/netbeans-8.0.2/bin/netbeans
![Page 32: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/32.jpg)
X11 build and rundocker build -t netbeansx11 .
docker run -ti --rm \ -e DISPLAY=$DISPLAY \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v $PWD/workspace:/workspace \ -v $PWD/m2:/root/.m2 \ -p 8081:8080 \ netbeansx11
![Page 33: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/33.jpg)
VNC
![Page 34: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/34.jpg)
![Page 35: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/35.jpg)
VNC DockerfileFROM java:8-jdkENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-get install -y xfce4 xvfb x11vnc supervisorRUN adduser --disabled-password --gecos '' johanADD vnc.conf /etc/supervisor/conf.d/// General partEXPOSE 5900CMD ["supervisord", "-n"]
![Page 36: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/36.jpg)
VNC vnc.conf[program:xvfb]
[program:x11vnc]command=/usr/bin/x11vnc -forever -display :1process_name = x11vncautorestart=trueuser=johan
[program:xfce4]command=/usr/bin/xfce4-sessionprocess_name = xfce4autorestart=trueuser=johanenvironment=DISPLAY=":1",HOME="/home/johan"
![Page 37: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/37.jpg)
VNC build and rundocker build -t netbeansvnc .
docker run -d \-v $PWD/workspace:/workspace \-v $PWD/m2:/root/.m2 \-p 5900:5900 \-p 8082:8080 \
netbeansvnc
![Page 38: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/38.jpg)
XRDP
![Page 39: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/39.jpg)
XRDP Dockerfile (1/2)FROM fedora:22RUN dnf -y groupinstall 'Xfce Desktop' && yum clean allCOPY Xclients /etc/skel/.XclientsRUN dnf -y install supervisor xrdp && dnf clean allRUN useradd johan && echo johan:secret | chpasswdCOPY xrdp.ini /etc/supervisord.d/
![Page 40: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/40.jpg)
XRDP Dockerfile (2/2)# Allow all users to connectRUN sed -i '/TerminalServerUsers/d' /etc/xrdp/sesman.ini && sed -i '/TerminalServerAdmins/d' /etc/xrdp/sesman.iniRUN dnf -y install java java-develENV JAVA_HOME /usr/lib/jvm/java-openjdk// General partEXPOSE 3389CMD ["supervisord", "-n"]
![Page 41: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/41.jpg)
XRDP xrdp.ini[program:xrdp-sesman]command=/usr/sbin/xrdp-sesman --nodaemonprocess_name = xrdp-sesman
[program:xrdp]command=/usr/sbin/xrdp -nodaemonprocess_name = xrdp
![Page 42: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/42.jpg)
XRDP build and rundocker build -t netbeansxrdp .
docker run -d \-v $PWD/workspace:/workspace \-v $PWD/m2:/root/.m2 \-p 3389:3389 \-p 8083:8080 \netbeansxrdp
![Page 43: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/43.jpg)
Used by multiple teams
![Page 44: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/44.jpg)
Used by multiple teams
Team Frodo image
Base image
Team Bilbo image
![Page 45: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/45.jpg)
Used by multiple teams•App Gimli•App Elrond
Team Frodo
•App ElrondTeam Bilbo
•App RadagastTeam Galadriel
App means
application server
etc.
![Page 46: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/46.jpg)
Used by multiple teams
Where do we place
the Elrond App?
•App Gimli•App Elrond
Team Frodo
•App ElrondTeam Bilbo
•App RadagastTeam Galadriel
![Page 47: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/47.jpg)
Splitting the containerTomcatImage
Gimli Elrond Radagast
![Page 48: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/48.jpg)
Splitting the containerFedoraImage
Development environment
![Page 49: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/49.jpg)
Docker Compose
![Page 50: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/50.jpg)
Docker Compose Define and run multi container Docker
applications Using a Compose file Link containers ‘docker-compose up’ to start the
containers
![Page 51: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/51.jpg)
Directory structure TomcatGimli
DockerFile TomcatElrond
DockerFile TomcatRadagast
Dockerfile DevEnv
Dockerfile docker-compose.yml
![Page 52: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/52.jpg)
tomcatgimli: build: TomcatGimli
tomcatelrond: build: TomcatElrond
tomcatradagast: build: TomcatRadagast
developmentenvironment: build: DevEnv ports: - "3389:3389" links: - tomcatgimli:gimli # Makes gimli available on # http://gimli:8080 - tomcatelrond:elrond - tomcatradagast:radagast
![Page 53: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/53.jpg)
One ring to rule them all
![Page 54: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/54.jpg)
Docker overview
![Page 55: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/55.jpg)
Docker registry Creating the Docker registry
docker run -p 5000:5000 registry
![Page 56: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/56.jpg)
Docker client 1 (push) Change container (using touch for instance) Commit
docker.io commit 064f192.168.56.31:5000/test-version-0.2
New containerid -> ff7e Push
docker.io push 192.168.56.31:5000/test-version-0.2
![Page 57: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/57.jpg)
Docker client 2 (pull) Pull
docker.io pull 192.168.56.31:5000/test-version-0.2
Rundocker.io run -i -t ff7e /bin/bash
![Page 58: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/58.jpg)
![Page 59: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/59.jpg)
![Page 60: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/60.jpg)
![Page 61: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/61.jpg)
![Page 62: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/62.jpg)
![Page 63: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/63.jpg)
![Page 64: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/64.jpg)
![Page 65: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/65.jpg)
![Page 66: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/66.jpg)
Summary Easy to use
Highly flexible and customizable
Start playing with Docker!
![Page 67: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/67.jpg)
Isolation
![Page 68: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/68.jpg)
Isolation
![Page 69: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/69.jpg)
Isolation
![Page 70: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/70.jpg)
Isolation
![Page 71: Hide your development environment and application in a container](https://reader033.vdocuments.net/reader033/viewer/2022052116/58832bc41a28abe2758b782f/html5/thumbnails/71.jpg)
Questions
https://bitbucket.org/johanjanssen/dockeride@johanjanssen42