Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Docker and java, at Montréal JUG

1 205 vues

Publié le

On Thursday the 28th of January 2016, Anthony Dahanne gave a talk on how to leverage Docker to package Java applications.
After a quick introduction to Docker principles, Anthony showed some demos (available on github) on how to create Docker images for simple and not so simple Java webapps.
Then, he went on with CI/CD examples, and finished with a quick intro to the Docker Java API.


Publié dans : Logiciels
  • Soyez le premier à commenter

Docker and java, at Montréal JUG

  2. 2. Anthony Dahanne, Software Engineer @ Terracotta, a Software AG company Working on the Terracotta Management Console, and its integration in Terracotta products And strong Docker supporter :-P , trying to containerize as much as I can ! LET ME INTRODUCE MYSELF We’re hiring Software Engineers ! Contact me !
  3. 3. AGENDA • Docker fundamentals : quick recap • Java applications in containers • Hello world from a Java container • SpringBoot app in a container (+ Maven + IntelliJ IDEA integrations) • Java Web Applications (war) Docker pipelines • Docker cloud based CI/CD • CI/CD using on premises familiar tools (Jenkins, Nexus) • Extras • Jenkins container-based slaves • Interacting with Docker from Java with Docker Java
  4. 4. VMS VS CONTAINERS IT’S ALL ABOUT THE (LINUX?) KERNEL ! picture from http://www.enterprisetech.com/2014/08/18/ibm-techies-pit-docker-kvm-bare-metal/
  5. 5. DOCKER CONTAINERS / IMAGES : A PILE OF LAYERS A DOCKER IMAGE IS A DIFF ON TOP OF ITS PARENT picture from : https://docs.docker.com/v1.6/terms/layer/
  6. 6. Host OS Docker daemon Images Containers Docker CLI > docker run ubuntu bash > docker ps > docker images > etc. Docker Compose > docker-compose build > docker-compose up > docker-compose kill > etc. Volumes Kinematic REST API tcp (tls) / Unix socket Host OS Docker daemon Ima ges Conta iners Volum es
  7. 7. DOCKER VOCABULARY VS JAVA VOCABULARY • Repository : houses grouped artifacts • Artifact : org.ehcache:ehcache:3.0.0.m4 (+type : jar/sources/etc.) Group id VersionArtifact id
  8. 8. DOCKER VOCABULARY VS JAVA VOCABULARY • Registry : hosts repositories • Repositories : house collections of tagged images • Image : localhost:5000/anthony/mycoolimage:v2 DockerHub / quay.io / Registry V2 Registry location Repository name Tag
  9. 9. Registry @ SoftwareAG anthony/tmc Registry ubuntu anthonydahanne/terracotta anthonydahanne/petclinic latest 12.04 latest 4.3.1- oss latest 5.0 Host OS Docker CLI Docker daemon Images Host OS Docker daemon Images Docker CLI REST API tcp (tls) / Unix socket
  10. 10. DEMO TIME ! • Hello world from a Java container • SpringBoot app in a container (+ Maven + IntelliJ IDEA integrations)
  11. 11. DOCKER CLOUD BASED CI/CD PUSH THAT CODE AROUND ! EC2 Azure GCE TutumGithub DockerHub Commit & Push Trigger Automated Build Trigger Redeploy / Scale Create & Start Container
  12. 12. DEMO TIME ! • Petclinic cloud based CI/CD • Petclinic built (war + image) by DockerHub • Deployed by Tutum
  13. 13. ON PREMISES CI/CD RE USING EXISTING INFRA ! Git Repo Jenkins Commit & Push Trigger mvn job Create & Start Container Docker daemons Regular Slaves Registry Image build Push image to registry Docker daemon
  14. 14. DEMO TIME ! • Petclinic built (war and then image) by Jenkins • Pushed to Nexus 3 by Jenkins • Deployed to a machine running Docker by Jenkins
  16. 16. EXTRAS INTERACTING WITH DOCKER WITH DOCKER JAVA DockerClient dockerClient = DockerClientBuilder.getInstance(dockerUrl).build(); Info info = dockerClient.infoCmd().exec(); List<Container> containers = dockerClient.listContainersCmd() .withShowAll(false) .exec(); CreateContainerResponse container = dockerClient.createContainerCmd("busybox") .withCmd("touch", "/test") .exec(); dockerClient.startContainerCmd(container.getId()).exec(); dockerClient.stopContainerCmd(container.getId()).exec(); <dependency> <groupId>com.github.docker-java</groupId> <artifactId>docker-java</artifactId> <version>2.1.2</version> </dependency> Demo at : https://github.com/anthonydahanne/montrealjug_docker_java/tree/04_spring_boot_app_docker_api
  17. 17. LINKS OF INTERESTS • Presentation links : http://blog.dahanne.net/2016/01/31/docker-and-java-notes-from-the-montreal-jug-presentation/ https://github.com/anthonydahanne/montrealjug_docker_java • Jenkins plugins https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin https://wiki.jenkins-ci.org/display/JENKINS/Support+Core+Plugin https://wiki.jenkins-ci.org/display/JENKINS/Docker+build+step+plugin https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Build+and+Publish+plugin https://updates.jenkins-ci.org/download/plugins/ • DockerHub repositories https://hub.docker.com/_/java/ https://hub.docker.com/_/jenkins/ https://hub.docker.com/_/tomcat/ https://hub.docker.com/_/maven/ https://hub.docker.com/r/anthonydahanne/terracotta-server-oss/ https://hub.docker.com/r/anthonydahanne/jenkins_with_plugins/ • Others https://wiki.eclipse.org/Linux_Tools_Project/Docker_Tooling/User_Guide https://plugins.jetbrains.com/plugin/7724 http://www.sonatype.org/nexus/2015/09/22/docker-and-nexus-3-ready-set-action/ https://github.com/docker/docker/issues/19396