Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Docker and java

251 visualizaciones

Publicado el

Presentation given during Confoo Montreal 2017

Publicado en: Software
  • Sé el primero en comentar

  • Sé el primero en recomendar esto

Docker and java

  1. 1. DOCKER AND JAVA ANTHONY DAHANNE, CONFOO MONTRÉAL, THURSDAY, MARCH 9TH, 2017 @anthonydahanne http://blog.dahanne.net
  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
  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) • Multi container deployment • Extras • CI/CD on premises (Jenkins, Nexus) vs cloud based deployment • Interacting with Docker from Java with Docker Java
  4. 4. DOCKER FUNDAMENTALS QUICK RECAP.
  5. 5. 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/
  6. 6. 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/
  7. 7. 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 Kitematic REST API tcp (tls) / Unix socket Host OS Docker daemon Ima Contai ners Volume
  8. 8. DOCKER VOCABULARY VS JAVA VOCABULARY • Repository : houses grouped artifacts • Artifact : org.ehcache:ehcache:3.1.3 (+type : jar/sources/etc.) Group id VersionArtifact id
  9. 9. DOCKER VOCABULARY VS JAVA VOCABULARY • Registry : hosts repositories • Repositories : house collections of tagged images • Image : localhost:5000/anthony/mycoolproduct:v2 DockerHub / quay.io / Registry V2 Registry location Repository name Tag
  10. 10. Host OS Docker daemon Images DockerHub Registry ubuntu latest 12.04 anthonydahanne/terracotta latest 4.3.1-oss anthonydahanne/petclinic Registry @ SoftwareAG anthony/tmc latest 5.0 Host OS Docker daemon Images Docker CLI Docker CLI REST API tcp (tls) / Unix socket
  11. 11. JAVA APPLICATIONS IN CONTAINERS FROM MAIN() TO THE CLOUD !
  12. 12. DEMO TIME ! • Hello world from a Java container • SpringBoot app in a container (+ Maven + IntelliJ IDEA integrations)
  13. 13. n … PostgreSQL Webapp with Ehcache3 Clustered Terracotta Server MULTI CONTAINER DEPLOYMENT Load Balancer + Webapp + Terracotta Server + PostgreSQL DB LoadBalancer
  14. 14. DEMO TIME ! • Ehcache demo image design • JHipster application with clustered caching • Depends on Terracotta Server and a Database • Ehcache demo cloud based deployment • 1 PostgreSQL Database • 1 Terracotta Server instance • n Webapp instances • 1 load balancer
  15. 15. EXTRAS CI/CD, OTHER JAVA INTEGRATIONS
  16. 16. Deployment infra. 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 Download Images
  17. 17. DOCKER CLOUD DEPLOYMENT PUSH THAT CODE AROUND ! EC2 Azure GCE DockerCloudGithub DockerHub Commit & Push Trigger Automated Build Trigger Redeploy / Scale Create & Start Container
  18. 18. JENKINS DOCKER PLUGIN : ADD CONTAINER BASED SLAVES
  19. 19. INTERACTING WITH THE DOCKER DAEMON 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>3.0.1</version> </dependency> Demo at available at : https://github.com/anthonydahanne/montrealjug_docker_java/tree/04_spring_boot_app_docker_api
  20. 20. LINKS OF INTERESTS • Docker labs, self paced (great to learn Docker !) https://training.docker.com/category/self-paced-online https://github.com/docker/labs/tree/master/beginner • Jenkins plugins 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 • DockerHub repositories https://hub.docker.com/_/openjdk/ https://hub.docker.com/_/jenkins/ https://hub.docker.com/_/maven/ https://hub.docker.com/r/anthonydahanne/terracotta-server-oss/ • Others https://wiki.eclipse.org/Linux_Tools_Project/Docker_Tooling/User_Guide https://plugins.jetbrains.com/plugin/7724 use socat with Docker For Mac ! http://www.sonatype.org/nexus/2015/09/22/docker-and-nexus-3-ready-set-action/ • Docker & Java talks The JVM and Docker. A good idea? by Christopher Batey Docker Tips & Tricks for Java Developers, by Ray Tsang
  21. 21. 21

×