Slide 1

Slide 1 text

Docker, but what it is? Introduction to Docker and its ecosystem

Slide 2

Slide 2 text

Who am I? • Julien Maitrehenry • DevOps, Cloud Architect, Developer • Co-founder @Kumojin • • •

Slide 3

Slide 3 text

Agenda • What is Docker? • Docker Compose • Orchestration • Docker Desktop • Questions? Photo by Ian Taylor on Unsplash

Slide 4

Slide 4 text

What is Docker?

Slide 5

Slide 5 text

But what does « Docker » mean? • An Open Source project and community • Tools from this project • A company: Docker inc.

Slide 6

Slide 6 text

And what is it for?

Slide 7

Slide 7 text

At the beginning • One goal • Linux only • Intel CPU only • A big and fat binnary

Slide 8

Slide 8 text

And now? • Linux and Windows containers • Running on Mac, Windows and Linux • Multi Architecture (intel, armv5-8, ppc, i386) • Split into many components • Component standardisation (OCI, CNCF) • Adopted by a large majority of cloud providers

Slide 9

Slide 9 text

What is a container? • An isolated space where an application run • Contain everything needed to run the application (libs, binaries, etc.) • Own its dedicated network stack, users, process, etc. • Share the host kernel • Could have some resource restriction (CPU, Ram, etc.)

Slide 10

Slide 10 text

How is it different from a VM?

Slide 11

Slide 11 text

How to create a container?

Slide 12

Slide 12 text

What is an image? • An union of layers • Each layers are immutable • Each layers are reusable

Slide 13

Slide 13 text

Let’s build a Docker image Base image Environnent variable Variable set during build Working directory Copy files into image Command executed during build Copy folder into image Default command that will be executed during a docker run

Slide 14

Slide 14 text

How to transform our file into an image? ❯ docker build -t myapp:v1.0.0 --build-arg NODE_ENV=development . Command to build an image Give a name and tag to the image Set a build variable Build context If the Dockerfile file has another name or is located elsewhere, it must be specified with: -f .docker/Dockerfile Warning : the context build is always the last parameter

Slide 15

Slide 15 text

How to run a container? - I can’t access my app from my browser - Ctr+C do not stop my app - The container name will be randomly generated - ex: goofy_kapitsa ❯ docker run myapp:v1.0.0 Command to run a container Image name and tag

Slide 16

Slide 16 text

How to run a container? ❯ docker run –ti -p 8080:80 --name myapp myapp:v1.0.0 Run in interactive mode and with a tty Link container port 80 to host port 8080 Give the name myapp to the container

Slide 17

Slide 17 text

How to run a container? ❯ docker run –d -p 8080:80 --name myapp myapp:v1.0.0 Run container in background ❯ docker run –ti –p 8080:80 --name myapp --rm myapp:v1.0.0 bash Automatically remove the container when stopped Change the default command (CMD)

Slide 18

Slide 18 text


Slide 19

Slide 19 text

Docker Engine • Client-Server application for managing • Images • Containers • Networks • Volumes • Has a REST API and a CLI

Slide 20

Slide 20 text

Volume • Keep data outside the container • Share data with host This Photo by Unknown Author is licensed under CC BY-SA-NC

Slide 21

Slide 21 text

Share folder/files between host and container ❯ docker run -ti --rm -v `pwd`/mydir:/data ubuntu Command for using a volume Local directory on host Directory in the container Be careful when mounting a file! Changes to file may not be reflected in container Ex: sed, vim, VS Code

Slide 22

Slide 22 text

Using a volume ❯ docker volume create mydata ❯ docker run -ti --rm -v mydata:/data ubuntu Command to manage volume Volume name Volume name instead of a path

Slide 23

Slide 23 text

Network • Allows you to: • create isolated network • Reproduce production network topology • Container can communicate with each other using by name, id or alias • Many network type/driver available: • Bridge (default) • Internal • None • Host

Slide 24

Slide 24 text

Internal network ❯ docker network create --internal intnet ❯ docker run --network intnet curlimages/curl -m3 ╰─❯ curl: (28) Resolving timed out after 3002 milliseconds Command to manage networks Network type Network name Attach the container to the intent network

Slide 25

Slide 25 text

Intra-container communication ❯ docker network create --driver bridge mynet ❯ docker run -d --network mynet --name nginx --network-alias web nginx ❯ docker run --rm --network mynet curlimages/curl -m3 http://web Use a specific network driver Adds an alias to the container in networks it is connected Container name or ID also works

Slide 26

Slide 26 text

Other useful network ❯ docker run --rm --network none curl -m3 ❯ docker run –d --network host nginx No network isolation between host and container Without network

Slide 27

Slide 27 text

Docker Compose

Slide 28

Slide 28 text

Let’s build a docker compose file DEPRECATED - No more used Services definition Networks definition Volumes definition

Slide 29

Slide 29 text

Let’s build a docker compose file Service name and its name on the network Container image If the container crash, docker will restart it List of volumes to attach to the container List of environment variables List of networks to attach to the container

Slide 30

Slide 30 text

Let’s build a docker compose file Override default image command You can attach a volume to a directory in another volume Definition for building the image Create a dependency on another service List of port to link to the host

Slide 31

Slide 31 text

Let’s build a docker compose file On a separate network from the database

Slide 32

Slide 32 text

How to use a compose file? ❯ docker compose ps -a List the containers created by compose Including those stopped ❯ docker compose logs -f [name of service(s)] Show logs And show new logs as they come ❯ docker compose up –d [name of service(s)] Command for compose Start service(s) In background

Slide 33

Slide 33 text

Registry Docker • Hosts Docker Images • Many online registry available: • Docker Hub • Azure ACR • AWS ECR • Github Registry • … • Many self-hosted solutions: • Docker Registry • Nexus • Artifactory • …

Slide 34

Slide 34 text

Useful commands ❯ docker login / docker login Connect Docker to a registry Pull an image locally Push a local image to a registry ❯ docker push jmaitrehenry/myimage ❯ docker pull Connect to a specific registry

Slide 35

Slide 35 text

Orchestration • For what? • Orchestration tools • Cloud solutions

Slide 36

Slide 36 text

For what? • Container supply and placement • Health check mechanism and metrics • Unavailability and scalability management • Deployment management • Service discovery and network management • And more!

Slide 37

Slide 37 text

Orchestration tools

Slide 38

Slide 38 text

Cloud Solutions • Kubernetes based • Azure: AKS • AWS: EKS • Google: GKE • Container based • Azure ACI • AWS Fargate • AWS ECS

Slide 39

Slide 39 text

Docker Desktop What is it? For what?

Slide 40

Slide 40 text