+ All Categories
Home > Documents > docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA...

docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA...

Date post: 28-May-2020
Category:
Upload: others
View: 24 times
Download: 0 times
Share this document with a friend
32
SAINT LOUIS JAVA USER GROUP MAY 2014 [email protected] STEVEN BORRELLI @stevendborrelli
Transcript
Page 1: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

S A I N T L O U I S J A VA U S E R G R O U P M A Y 2 0 1 4

[email protected]

S T E V E N B O R R E L L I

@stevendborrelli

Page 2: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

A B O U T M E

F O U N D E R , A S T E R I S ( J A N 2 0 1 4 ) @

O R G A N I Z E R O F S T L M A C H I N E L E A R N I N G A N D D O C K E R S T L

S Y S T E M S E N G I N E E R I N G M A N A G E M E N T

F I R S T C O M P U T E R :

aster.is

Page 3: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

W H Y D O C K E R ?

Docker makes it easy to:

Package

Deploy

Share

Server Applications

Page 4: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

Think:

java -jar

vs.

./configure; make install !

Page 5: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

D O C K E R FA C T S

Written by Docker, Inc. (Formerly Dotcloud)

Automates the management and control of Linux containers

Rewrite of their proprietary PAAS container engine (written in Python)

Written in Go / Apache 2 License

11,700+ Github stars

Page 6: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

D O C K E R T I M E L I N E

M A R C H 2 0 1 3 : I N I T I A L G I T H U B R E L E A S E

M AY 7 , 2 0 1 4 : 0 . 1 1 R E L E A S E

M O N T H LY R E L E A S E C A D E N C E

J A N U A R Y 2 0 1 3 : P R O J E C T S TA R T

M AY 8 , 2 0 1 4 : 0 . 1 1 . 1 R E L E A S E

Page 7: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

(LINUX) KERNEL

LAYER FSCGROUPS NAMESPACES

LIBCONTAINER

DOCKER

LXC

D O C K E R A R C H I T E C T U R E

Page 8: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

N A M E S PA C E S V S . C G R O U P S Namespaces provide isolation:

• pid (processes)

• net (network interfaces, routing...)

• ipc (System V IPC)

• mnt (mount points, filesystems)

• uts (hostname)

• user (UIDs)

Control groups control resources:

• cpu (CPU shares)

• cpusets (limit processes to a CPU)

• memory (swap, dirty pages,

• blockio (throttle reads/writes)

• devices

• net_cls, net_prio: control packet class and priority

Page 9: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

What’s the difference between containers and virtual machines (VMs)?

!

Page 10: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

V I RT U A L I Z AT I O N

Page 11: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

1966-1972 IBM CP/CMS

1989 Insignia SoftPC

1997 Connectix VirtualPC

1999 VMWare Workstation

2001 IBM AIX LPAR

2002 Xen

2006 Amazon EC2

2007 Sun Logical Domains

2007 Linux KVM

2007 InnoTek VirtualBox

2008 Microsoft Hyper-V

H A R D WA R E V I RT U A L I Z AT I O N

Page 12: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

C O N TA I N E R S

Page 13: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

P R O C E S S V I RT U A L I Z AT I O N

1979-1982 UNIX Chroot

1998 FreeBSD Jail

2001 Parallels Virtuozzo

2001 Linux-VServer

2005 Solaris Zones

2005 OpenVZ

2008 Linux LXC

2007+PAAS:

Heroku, Joyent, CloudFoundry

2013 Docker

Page 14: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

Differences between containers and virtual machines

!• Weaker isolation in containers

• Containers run near-native speed CPU/IO

• Containers launch in around 0.1 second (libcontainer)

• Less memory overhead

Page 15: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

N O TA B L E C H A N G E S

0 . 9 : L I B C O N TA I N E R

Page 16: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

N O TA B L E C H A N G E S

0 . 1 0 :

• TLS support on docker API

• Systemd integration via API instead of /proc

• Lots of cleanups

Page 17: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

N O TA B L E C H A N G E S

0 . 1 1 :

• Release Candidate for 1.0

• Multiple registries

• Direct host network access

• SELinux support

Page 18: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

EXAMPLES

Page 19: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

R U N N I N G A C O N TA I N E R

Start a container:

Mount host filesystems:

Page 20: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

Example: run Zookeeper + Exhibitor

Host ports will be dynamically allocated by docker

Port 2181 on host will be mapped to 2181 on container

M A P P I N G P O RT S

Page 21: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

New in 0.11, allows a container to access host adapters:

D I R E C T H O S T N E T W O R K

Port 8080 on the container is 8080 on the host:

Page 22: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

I M M U TA B L E S E R V E R S

Physical server lifetime is measured in years.

A container's lifetime can be as short as a few seconds.

Treat containers like a build artifact. 

If you need to make changes, build a new container.

Page 23: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

J AVA D O C K E R F I L E

Page 24: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

T O M C AT D O C K E R F I L E

Page 25: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

L AY E R E D F S I S A G R A P H

Page 26: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

R U N N I N G J AVA I N D O C K E R

• Pass in environment variables to Java vars (i.e. in start.sh): java -Dkeystore.password=${KEY_PASS}

• When you run the container, set the vars:

docker run -e SSL_PASS=password tomcat

Problem: keep configuration out of containers

Page 27: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

R U N N I N G J AVA I N D O C K E R

• Link from a volume containerdocker run -v /opt/properties -v /opt/ssl \ -name TOMCAT-CFG busybox true docker run -t -i -rm -volumes-from TOMCAT-CFG -name appsrv1 tomcat

• Mount host filesystem:

docker run -v/opt/ssl:/opt/ssl tomcat

Problem: keep configuration out of containers

Page 28: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

R U N N I N G J AVA I N D O C K E R

Running stateless containers

• Use a redis/DB to store session data

• Use a shared FS (hdfs/nfs, etc.) or Object storage (Swift, S3) for data

• Send logs to a centralized location

• Docker future: storage plugins

Page 29: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

W H AT ’ S N E X T ?

Stripped-down operating systems

Page 30: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

W H AT ’ S N E X T ?

New operational models:

Continuous Delivery

Automated routing

Distributed consensus (Paxos, Raft)

Service Discovery (Zookeeper, etcd, serf, skydns, consul)

Distributed scheduling (Fleet, Mesos, YARN)

Page 31: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

S U M M A RY

Easy to build, run & share containers

Rapidly expanding ecosystem

Better performance vs. VMs

Layered filesystem gives us git-like control of images.

Reduces complexity of system builds

Page 32: docker may 2014 - Object Computingjava.ociweb.com/.../2014-05/docker_may_2014.pdf · RUNNING JAVA IN DOCKER Running stateless containers • Use a redis/DB to store session data •

Q & A


Recommended