1
Introduction To
Docker, Docker Compose, Docker Swarm
2
About me
An Nguyen
Email: nthienan.it@gmail.com
6+ years of experience in software industry
Java, Python developer, DevOps engineer at TMA Solutions
3
Agenda
 Docker
 Docker Compose
 Docker Swarm
4
 Who knows about Docker?
 Who uses Docker for development?
 Who uses Docker in production?
 Who tried but could not do it?
5
What is Docker?
 Docker is container engine
6
What is Docker? (cont.)
 Docker is an open platform for developing,
shipping, and running applications.
 Docker allows you to package an application with
all of its dependencies into a standardized unit for
software development.
7
What is Docker? (cont.)
 Standardized packaging for software and dependencies
 Isolate apps from each other
 Share the same OS kernel
 Works for all major Linux distributions
 Containers native to Windows Server 2016
8
Virtual Machine vs Container
9
History of Docker
10
Benefits of Docker
 Fast (deployment, migration, restarts)
 Secure
 Lightweight (save disk & CPU)
 Open Source
 Portable software
 Micro-services and integrations (APIs)
 Simplify DevOps
 Version control capabilities
11
Technologies behind Docker
 Linux x86-64
 Go language
 Client - Server (deamon) architecture
 Union file systems (UnionFS: AUFS, btrfs, vfs etc)
 Namespaces (pid, net, ipc, mnt, uts)
 Control Groups (cgroups)
 Container format (libcontainer)
12
Docker architecture
https://docs.docker.com/engine/docker-overview/#docker-architecture
13
Docker Vocabulary
 Docker client
● Is the primary user interface to Docker.
● Accepts commands from the user and communicates back and forth with a
Docker daemon
 Docker daemon
● Runs on a host machine.
● Users do not directly interact with the daemon, but instead through the Docker
client with the RESTful API or sockets
14
Docker Vocabulary (cont.)
 Image
● Is a read-only template with instructions for creating
a Docker container.
● An image is based on another image, with some
additional customization
 Container
● Is a runnable instance of an image.
● A container is removed, any changes to its state that
are not stored in persistent storage disappear
15
Docker Vocabulary (cont.)
 Registry
● A Docker registry stores Docker images.
● Docker Hub and Docker Cloud are public registries that anyone can use
● You can run your own private registry
16
Docker Vocabulary (cont.)
 Dockerfile
● Is a text document that contains all the commands a user could call on the command line to
create an image
● Dockerfile reference on docker docs
17
Docker Vocabulary (cont.)
 Volume
● Is a mount point on the container’s directory tree where a portion of the host directory tree has
been mounted
18
Demo Time
19
Common Docker usages
 Sandbox environment (develop, test, debug, educate)
 Continuous Integration & Deployment
 Scaling apps
 Development collaboration
 Infrastructure configuration
 Local development
 Multi-tier applications
 PaaS, SaaS
20
Useful resources
 Awesome Docker (list of Docker resources & projects)
 Docker cheat sheet
 Docker in Practice, The Docker Book (books)
 Docker aliases/shortcuts
 Docker case studies
 Self-learning courses
21
Docker Compose
22
Real life applications
 One application consists of multiple containers.
 One container is dependent on another.
 Mutual dependency/ startup order.
 Process involves building containers and then deploy them
 Long docker run commands
 Complexity is proportional to the number of containers involved
23
What is Docker compose?
 Tool for defining and running multi-container Docker application.
 It is a YML file.
 Compose contains information about how to build the containers and deploy
containers.
 Integrated with Docker Swarm
24
Demo Time
25
Docker Swarm
26
What is Docker swarm?
 Is a clustering and scheduling tool for Docker containers. With Swarm, IT
administrators and developers can establish and manage a cluster of Docker
nodes as a single virtual system
 A swarm is a group of machines that are running Docker and joined into a cluster
27
Swarm architecture
28
Feature highlights
 Cluster management integrated with Docker Engine
● Use the Docker Engine CLI to create a swarm of Docker Engines where you can deploy
application services
 Declarative service model
● Uses a declarative approach to let you define the desired state of the various services in your
application stack
 Scaling
● When you scale up or down, the swarm manager automatically adapts by adding or removing
tasks to maintain the desired state
29
Feature highlights (cont.)
 Desired state reconciliation
● Swarm manager node constantly monitors the cluster state and reconciles any differences
between the actual state and your expressed desired state
 Service discovery
● Swarm manager nodes assign each service in the swarm a unique DNS name and load balances
running containers
 Rolling updates
● At rollout time you can apply service updates to nodes incrementally. If anything goes wrong,
you can roll-back a task to a previous version of the service
30
Routing mesh
31
Core concepts
 Service:
● Services are really just “containers in production”
● A service only runs one image, but it codifies the way that image runs—what ports it should use,
how many replicas of the container should run so the service has the capacity it needs, and so
on
● Scaling a service changes the number of container instances running that piece of software
32
Core concepts (cont.)
Two type of service:
 Replicated
● Specify the number of identical tasks you
want
 Global
● Service that runs one task on every node
33
Core concepts (cont.)
 Stack:
● A stack is a group of interrelated services that share dependencies, and can be orchestrated and
scaled together
● A single stack is capable of defining and coordinating the functionality of an entire application
(though very complex applications may want to use multiple stacks)
34
Demo Time
35
Q&A
36
Thank You!

Introduction To Docker, Docker Compose, Docker Swarm

  • 1.
    1 Introduction To Docker, DockerCompose, Docker Swarm
  • 2.
    2 About me An Nguyen Email:nthienan.it@gmail.com 6+ years of experience in software industry Java, Python developer, DevOps engineer at TMA Solutions
  • 3.
    3 Agenda  Docker  DockerCompose  Docker Swarm
  • 4.
    4  Who knowsabout Docker?  Who uses Docker for development?  Who uses Docker in production?  Who tried but could not do it?
  • 5.
    5 What is Docker? Docker is container engine
  • 6.
    6 What is Docker?(cont.)  Docker is an open platform for developing, shipping, and running applications.  Docker allows you to package an application with all of its dependencies into a standardized unit for software development.
  • 7.
    7 What is Docker?(cont.)  Standardized packaging for software and dependencies  Isolate apps from each other  Share the same OS kernel  Works for all major Linux distributions  Containers native to Windows Server 2016
  • 8.
  • 9.
  • 10.
    10 Benefits of Docker Fast (deployment, migration, restarts)  Secure  Lightweight (save disk & CPU)  Open Source  Portable software  Micro-services and integrations (APIs)  Simplify DevOps  Version control capabilities
  • 11.
    11 Technologies behind Docker Linux x86-64  Go language  Client - Server (deamon) architecture  Union file systems (UnionFS: AUFS, btrfs, vfs etc)  Namespaces (pid, net, ipc, mnt, uts)  Control Groups (cgroups)  Container format (libcontainer)
  • 12.
  • 13.
    13 Docker Vocabulary  Dockerclient ● Is the primary user interface to Docker. ● Accepts commands from the user and communicates back and forth with a Docker daemon  Docker daemon ● Runs on a host machine. ● Users do not directly interact with the daemon, but instead through the Docker client with the RESTful API or sockets
  • 14.
    14 Docker Vocabulary (cont.) Image ● Is a read-only template with instructions for creating a Docker container. ● An image is based on another image, with some additional customization  Container ● Is a runnable instance of an image. ● A container is removed, any changes to its state that are not stored in persistent storage disappear
  • 15.
    15 Docker Vocabulary (cont.) Registry ● A Docker registry stores Docker images. ● Docker Hub and Docker Cloud are public registries that anyone can use ● You can run your own private registry
  • 16.
    16 Docker Vocabulary (cont.) Dockerfile ● Is a text document that contains all the commands a user could call on the command line to create an image ● Dockerfile reference on docker docs
  • 17.
    17 Docker Vocabulary (cont.) Volume ● Is a mount point on the container’s directory tree where a portion of the host directory tree has been mounted
  • 18.
  • 19.
    19 Common Docker usages Sandbox environment (develop, test, debug, educate)  Continuous Integration & Deployment  Scaling apps  Development collaboration  Infrastructure configuration  Local development  Multi-tier applications  PaaS, SaaS
  • 20.
    20 Useful resources  AwesomeDocker (list of Docker resources & projects)  Docker cheat sheet  Docker in Practice, The Docker Book (books)  Docker aliases/shortcuts  Docker case studies  Self-learning courses
  • 21.
  • 22.
    22 Real life applications One application consists of multiple containers.  One container is dependent on another.  Mutual dependency/ startup order.  Process involves building containers and then deploy them  Long docker run commands  Complexity is proportional to the number of containers involved
  • 23.
    23 What is Dockercompose?  Tool for defining and running multi-container Docker application.  It is a YML file.  Compose contains information about how to build the containers and deploy containers.  Integrated with Docker Swarm
  • 24.
  • 25.
  • 26.
    26 What is Dockerswarm?  Is a clustering and scheduling tool for Docker containers. With Swarm, IT administrators and developers can establish and manage a cluster of Docker nodes as a single virtual system  A swarm is a group of machines that are running Docker and joined into a cluster
  • 27.
  • 28.
    28 Feature highlights  Clustermanagement integrated with Docker Engine ● Use the Docker Engine CLI to create a swarm of Docker Engines where you can deploy application services  Declarative service model ● Uses a declarative approach to let you define the desired state of the various services in your application stack  Scaling ● When you scale up or down, the swarm manager automatically adapts by adding or removing tasks to maintain the desired state
  • 29.
    29 Feature highlights (cont.) Desired state reconciliation ● Swarm manager node constantly monitors the cluster state and reconciles any differences between the actual state and your expressed desired state  Service discovery ● Swarm manager nodes assign each service in the swarm a unique DNS name and load balances running containers  Rolling updates ● At rollout time you can apply service updates to nodes incrementally. If anything goes wrong, you can roll-back a task to a previous version of the service
  • 30.
  • 31.
    31 Core concepts  Service: ●Services are really just “containers in production” ● A service only runs one image, but it codifies the way that image runs—what ports it should use, how many replicas of the container should run so the service has the capacity it needs, and so on ● Scaling a service changes the number of container instances running that piece of software
  • 32.
    32 Core concepts (cont.) Twotype of service:  Replicated ● Specify the number of identical tasks you want  Global ● Service that runs one task on every node
  • 33.
    33 Core concepts (cont.) Stack: ● A stack is a group of interrelated services that share dependencies, and can be orchestrated and scaled together ● A single stack is capable of defining and coordinating the functionality of an entire application (though very complex applications may want to use multiple stacks)
  • 34.
  • 35.
  • 36.