docker recipes for java developers - red hat · docker swarm • native clustering for docker •...

16
Docker Recipes for Java Developers Arun Gupta, @arungupta

Upload: trancong

Post on 20-Jan-2019

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Docker Recipes for Java Developers

Arun Gupta, @arungupta

Page 2: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

What is Docker?• Open source project and company

• Used to create containers for software applications

• Package Once Deploy Anywhere (PODA)

Page 3: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

https://gist.github.com/arun-gupta/7d5a373099ff831d7213http://www.infoworld.com/article/2925484/application-virtualization/look-whos-helping-build-docker-besides-docker-itself.html

Page 4: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with
Page 5: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with
Page 6: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Docker Hub

Image 1

Image 2

Image 3

Image M

Docker Host

Image 1

Image 2

Image 3

Image N

Daemon

Container 1

Container 2

Container O

Docker Client

docker run <image> docker …

Docker Workflow

Page 7: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Docker Machine• Create Docker Host on computer or cloud provider docker-machine create --driver=virtualbox myhost

• Configure Docker client to talk to host

• Create and pull images

• Start, stop, restart containers

• Upgrade Docker

• Not recommended for production yet

Page 8: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Docker Compose

• Defining and running multi-container applications

• Configuration defined in a single file

• Great for dev, staging, and CI

• Not recommended for production yet

Page 9: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

docker-compose.ymlmysqldb: image: mysql environment: MYSQL_DATABASE: sample MYSQL_USER: mysql MYSQL_PASSWORD: mysql MYSQL_ROOT_PASSWORD: supersecret mywildfly: image: arungupta/wildfly-mysql-javaee7 links: - mysqldb:db

Page 10: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Docker Swarm• Native clustering for Docker

• Provides a unified interface to a pool of Docker hosts

• Fully integrated with Machine

• Serves the standard Docker API

• Partially integrated with Compose

• Not recommended for production yet

10

Page 11: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

http://blog.arungupta.me/clustering-docker-swarm-techtip85/

Page 12: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Machine Swarm

Compose

YAML

Page 13: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Advantages of Containers• Immutability

• Reproducibility

• Isolation

• Faster deployments

• Portability - “it works on my machine”

• Snapshotting

• Security sandbox

• Limit resource usage

• Simplified dependency

• Sharing

13

Page 14: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Kubernetes• Open source orchestration system for Docker

containers

• Provide declarative primitives for the “desired state”

• Self-healing

• Auto-restarting

• Schedule across hosts

• Replicating

14

Page 15: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

Concepts• Pods: collocated group of

Docker containers that share an IP and storage volume

• Service: Single, stable name for a set of pods, also acts as LB

• Replication Controller: manages the lifecycle of pods and ensures specified number are running

• Label: used to organize and select group of objects

DockerPod 1 Pod 2

C1 C2 C3

Pod 1

JBoss

Pod 2

JBoss

Service “web”

port 8080 port 8080

15

Page 16: Docker Recipes for Java Developers - Red Hat · Docker Swarm • Native clustering for Docker • Provides a unified interface to a pool of Docker hosts • Fully integrated with

16