Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2017 DevNexus - Docker Tips & Tricks for Java Developers

Ray Tsang
February 24, 2017

2017 DevNexus - Docker Tips & Tricks for Java Developers

Presented at 2017 DevNexus. https://devnexus.com/s/devnexus2017/presentations/17356

Most of the presentation was live coded/demonstrated rather than going through these slides. But these captures most of what I showed.

Parts of the talk also shared what I learned here:
https://medium.com/google-cloud/my-slow-internet-vs-docker-7678ae1cae72#.5aj7ych1c
https://medium.com/google-cloud/deep-dream-with-containers-d28a26e4c8a3#.dmx9a66nc

Ray Tsang

February 24, 2017
Tweet

More Decks by Ray Tsang

Other Decks in Technology

Transcript

  1. @saturnism @googlecloud #kubernetes #devnexus Guestbook UI Hello World Service Redis

    session replication greeting MySQL Guestbook Service CRUD
  2. @saturnism @googlecloud #kubernetes #devnexus Machine app.war / app.ear Application Server

    Kernel Shell / CLI / Tools Machine app.war / app.ear Application Server Kernel Shell / CLI / Tools Machine app.war / app.ear Application Server Kernel Shell / CLI / Tools
  3. @saturnism @googlecloud #kubernetes #devnexus Old Way: Shared machines kernel libs

    app app app No isolation No namespacing Common libs Highly coupled apps and OS app
  4. @saturnism @googlecloud #kubernetes #devnexus Old Way: Virtual machines Some isolation

    Expensive and inefficient Still highly coupled to the guest OS Hard to manage app libs kernel libs app app kernel app libs libs kernel kernel
  5. @saturnism @googlecloud #kubernetes #devnexus Versioning container image docker tag spring-boot-demo

    spring-boot-demo:1.0 docker tag spring-boot-demo spring-boot-demo:1.0-k39fa
  6. @saturnism @googlecloud #kubernetes #devnexus Combine RUN commands apt-get update &&

    \ apt-get install -y --no-install-recommends ... && \ rm -rf /var/lib/apt/lists/* Saves you space.
  7. @saturnism @googlecloud #kubernetes #devnexus Don’t Log to Container Filesystem! Log

    to a volume… docker -v /tmp/log:/log Or, better yet, Send it elsewhere! I prefer STDOUT
  8. @saturnism @googlecloud #kubernetes #devnexus Clean up disk spaces Every image,

    layer, and, even containers litters docker rm $(docker ps -a -q) docker rmi $(docker images -q --filter dangling=true)
  9. @saturnism @googlecloud #kubernetes #devnexus How many CPUs? Red Hat has

    it right - check their scripts! Don't trust Runtime.availableProcessors() https://github.com/fabric8io-images/run-java-sh
  10. @saturnism @googlecloud #kubernetes #devnexus How much memory? Check Red Hat's

    script! https://github.com/fabric8io-images/run-java-sh java -XX:+PrintFlagsFinal -version | grep HeapSize
  11. @saturnism @googlecloud #kubernetes #devnexus MySQL docker run -d --name mysql

    -p 3306:3306 -e MYSQL_ROOT_PASSWORD=yourpassword -e MYSQL_DATABASE=app mysql
  12. @saturnism @googlecloud #kubernetes #devnexus Guestbook Service docker run -ti --name

    guestbookservice --link mysql:mysql saturnism/guestbook-service
  13. @saturnism @googlecloud #kubernetes #devnexus Hello World Service docker run -ti

    --name helloworldservice \ saturnism/spring-boot-helloworld-service:1.0
  14. @saturnism @googlecloud #kubernetes #devnexus Guestbook UI docker run -ti --rm

    --link redis:redis \ --link helloworldservice:helloworldservice \ --link guestbookservice:guestbookservice \ -p 8080:8080 saturnism/spring-boot-helloworld-ui
  15. @saturnism @googlecloud #kubernetes #devnexus Use an Orchestrator! Don't deploy containers

    to individual machines yourself… Let an orchestrator do it for you!