28
in 30 mins Steve Poole, IBM @spoole167

Docker in 30 minutes

Embed Size (px)

Citation preview

Page 1: Docker in 30 minutes

in 30 minsSteve Poole, IBM

@spoole167

Page 2: Docker in 30 minutes

the promise

Page 3: Docker in 30 minutes

Ship a complicated software environment that leaves no trace when finished…

Be total confident that if it works for me it will work the same for you

https://localhost:9043/ibm/console/logon.jsp

docker run --name test -h test -v $(pwd)/PASSWORD:/tmp/PASSWORD \ -p 9043:9043 -p 9443:9443 -d ibmcom/websphere-traditional:install

Page 4: Docker in 30 minutes

The basics

Page 5: Docker in 30 minutes

Docker Engine

Server(Long

running Daemon)

Host (linux)

REST API

CLI

You

Image Image

UI

Registry

Page 6: Docker in 30 minutes

Docker Engine

Server(Long

running Daemon)

Host (not linux)

REST API

CLI

You

Image Image

UI

VM (linux)

Registry

Page 7: Docker in 30 minutes

Docker Engine

DaemonAPI

You

Image Image

Host

Registry

Page 8: Docker in 30 minutes

Docker Engine

Daemon

Host

API

You

Image Image

docker run -d –p 8080:80 presentation

Registry

Page 9: Docker in 30 minutes

Docker Engine

Daemon

Host

API

You

Image Image

Registry

Presentation

Image cache

Container

8080

:8080

:80

Page 10: Docker in 30 minutes

docker run -d –p 8080:80 presentation

docker run -d –p 8081:80 presentation

docker ps

Page 11: Docker in 30 minutes

quick check• Images are the unit of delivery. You only share images• Images are immutable• Images are stored in local caches or shared via registries.• DockerHub is a central point Think “github” for docker images• Containers are the runtime units. They run on a single host• Containers retain state until terminated• Containers are the unit of scale.

• docker ps lists the running containers • docker ps -a lists all containers

Page 12: Docker in 30 minutes

Let’s build a Docker Image

Page 13: Docker in 30 minutes

docker build -t presentation .

Page 14: Docker in 30 minutes

Docker images are layers in a union file system. Each layer overlays the ones before:

presentation

eboraas/apache

eboraas/debian

eboraas/debootstrap

Page 15: Docker in 30 minutes

Dockerfile - automated image creationFROM eboraas/apache COPY ./DockerIn30Minutes /var/www/html

Where’s the command to run the apache server? I inherited it

Page 16: Docker in 30 minutes

FROM eboraas/debian:stableMAINTAINER Ed Boraas <[email protected]>

RUN apt-get update && apt-get -y install apache2 && apt-get clean \ && rm -rf /var/lib/apt/lists/*

ENV APACHE_RUN_USER www-dataENV APACHE_RUN_GROUP www-dataENV APACHE_LOG_DIR /var/log/apache2

RUN /usr/sbin/a2ensite default-sslRUN /usr/sbin/a2enmod ssl

EXPOSE 80EXPOSE 443

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

Page 17: Docker in 30 minutes

quick check• Dockerfiles are the normal way to create docker images.

• Usually:

• has a name of image to inherit from• has a set of build instructions to run at build time• has some runtime instruction (ie what to start)

Page 18: Docker in 30 minutes

Docker Engine

Daemon

Host

API

You

Image Image

Registry

Presentation

Image cache

Container

8080

:8080

:80

Page 19: Docker in 30 minutes

Docker Engine

Daemon

Host

API

You

Image Image

Registry

pres

Image cache

Container

8080

Container

8081

apache

debian

Page 20: Docker in 30 minutes

Volumes• Think of containers as mini VM’s • Any mutations made to the containers contents will be lost when the

container is stopped• How to share or persist state?

• Two options..

Page 21: Docker in 30 minutes

docker run -d -v $PWD:/var/www/html p 8082:80 —t presentation

Think of as an nfs mount style command

mounts a local directory on the host over the top of a directory in the container

Both directory paths must be absolute

The container can read/write the contents of the host file system

-v

Page 22: Docker in 30 minutes

VOLUME command

VOLUME /data

Dockerfile command to create a persistent data store on the host system that isaccessed inside the container at the path given.

Volumes persist on the host until deleted.

Volumes are a great way to share state between containers

docker run -d —volumes-from container image

auto magically mount the volumes created by another container

Page 23: Docker in 30 minutes

Docker Engine

Daemon

Host

API

You

Image Image

Registry

pres

Image cache

Container

8080

Container

8081

apache

debian

Page 24: Docker in 30 minutes

It’s getting messy

• Let me introduce kitematic

Page 25: Docker in 30 minutes

Advanced section• Docker for encapsulating a single instance of a complex environment is

useful

• Docker as the packing and deployment of an single micro service is compelling

• Docker tools exist to network containers together and to scale and load balance across multiple hosts and data centres.

• Containerisation is the enabler for industrial application deployments on truly gigantic scales.

Page 26: Docker in 30 minutes

Docker compose• “Compose is a tool for defining and running multi-container Docker

applications. With Compose, you use a Compose file to configure your application’s services. Then, using a single command, you create and start all the services from your configuration”

• https://docs.docker.com/compose/overview/

Page 27: Docker in 30 minutes

version: '2'

services: dbserver: image: couchdb ports: - "5984:5984" volumes: - ./.couchsummary:/usr/local/var/lib/couchdb

dbteam: image: couchdb ports: - "5985:5984" volumes: - ./.couchteam:/usr/local/var/lib/couchdb

teamserver: image: dashboard build: . command: bundle exec rackup -s puma -p 8080 volumes: - .:/dashboard ports: - "80:8080" depends_on: - dbteam environment: MODE: team TEAM: test DBURL: http://dbteam:5984/

Page 28: Docker in 30 minutes

There’s more - but thats for another talk

thank you.