Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker, but what it is?

Docker, but what it is?

Introduction to Docker and its ecosystem

Julien Maitrehenry

June 10, 2022

More Decks by Julien Maitrehenry

Other Decks in Technology


  1. Who am I? • Julien Maitrehenry • DevOps, Cloud Architect,

    Developer • Co-founder @Kumojin • Kumojin.com • Github.com/jmaitrehenry • jmaitrehenry.ca
  2. Agenda • What is Docker? • Docker Compose • Orchestration

    • Docker Desktop • Questions? Photo by Ian Taylor on Unsplash
  3. But what does « Docker » mean? • An Open

    Source project and community • Tools from this project • A company: Docker inc.
  4. At the beginning • One goal • Linux only •

    Intel CPU only • A big and fat binnary
  5. 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
  6. 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.)
  7. What is an image? • An union of layers •

    Each layers are immutable • Each layers are reusable
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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)
  13. Docker Engine • Client-Server application for managing • Images •

    Containers • Networks • Volumes • Has a REST API and a CLI
  14. Volume • Keep data outside the container • Share data

    with host This Photo by Unknown Author is licensed under CC BY-SA-NC
  15. 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
  16. 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
  17. 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
  18. Internal network ❯ docker network create --internal intnet ❯ docker

    run --network intnet curlimages/curl -m3 https://google.com ╰─❯ curl: (28) Resolving timed out after 3002 milliseconds Command to manage networks Network type Network name Attach the container to the intent network
  19. 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
  20. Other useful network ❯ docker run --rm --network none curl

    -m3 https://google.com ❯ docker run –d --network host nginx No network isolation between host and container Without network
  21. Let’s build a docker compose file DEPRECATED - No more

    used Services definition Networks definition Volumes definition
  22. 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
  23. 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
  24. 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
  25. 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 • …
  26. Useful commands ❯ docker login / docker login kumojin.azurecr.io Connect

    Docker to a registry Pull an image locally Push a local image to a registry ❯ docker push jmaitrehenry/myimage ❯ docker pull kumojin.azurecr.io/myapp/api:v1.0.0 Connect to a specific registry
  27. For what? • Container supply and placement • Health check

    mechanism and metrics • Unavailability and scalability management • Deployment management • Service discovery and network management • And more!
  28. Cloud Solutions • Kubernetes based • Azure: AKS • AWS:

    EKS • Google: GKE • Container based • Azure ACI • AWS Fargate • AWS ECS