Docker

What is docker, again?

Who it is for?

How its different from VM?

How does it work?

Basics

# build an image using a dockerfile
$ docker build <image>

# run an image
$ docker run <image>

# push it to the docker registry
$ docker push <image>

# pull an image from docker registry
$ docker pull <image>

# show a list of docker containers
$ docker ps

# show a list of docker images
$ docker images

# delete an image or a container
$ docker rm/rmi <container/image>

Show off

Exercise

create a container that doesn't die.

Vocabulary

  • Images?
  • Containers?
  • Registry?
  • Hub?
  • Repository?
  • Compose?
  • Node?
  • Base Image?

Show off #2

Example Application

Let's dig deeper.

But before that,
lets debug.

Show off #3

Environment
Variables

Linking

# create an application that uses redis and run it with docker
$ docker run --rm -e REDIS_ADDR='redis:6379' -t umayr/redis-hello # wouldn't work, no redis.

# run a redis container
$ docker run --rm -d --name redis-server -t redis

# link the redis container with app
$ docker run --rm --link redis-server:redis -e REDIS_ADDR='redis:6379' -t umayr/redis-hello

Mounting


# create a persistent redis container
$ docker run --rm -d --name redis-server -v (pwd)/data:/data -t redis --appendonly yes 

# run the app again with persistent backend
$ docker run --rm --link redis-server:redis -e REDIS_ADDR='redis:6379' -t umayr/redis-hello

Exercise

Create a container that generates logs, try to pass these logs to another container that displays them.

Compose

Show off #4

Exercise

Use compose instead of manually linking and mounting the previous app.

Questions

Made with Slides.com