SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
An Introduction to Docker
1
Ruben Taelman - @rubensworks
imec - Ghent University
So what is Docker?
Platform for running software in isolated containers
2
So what is Docker?
Platform for running software in isolated containers
3
Traditional webserver
NGINX
PostgreSQL
Node
So what is Docker?
Platform for running software in isolated containers
4
Traditional webserver Docker webserver
NGINX
PostgreSQL
Node
NGINX
PostgreSQL
Node
So what is Docker?
Platform for running software in isolated containers
5
Traditional webserver Docker webserver
NGINX
PostgreSQL
Node
NGINX
PostgreSQL
Node
✓Linux ✓Windows ✓Mac
(Reproducible) software evaluations
Easily installable and disposable software
Running different software versions simultaneously
What to use Docker for?
6
Overview
Basics
Networks
Convenience tools
7
Overview
Basics
Networks
Convenience tools
8
Virtual machines vs containers
(Docker) containers don’t need separate OS’s, so they are more lightweight.
9
Docker workflow
10
Dockerfile Image Container
Build Run
Description of an image Built image
Available for reuse
Instantiated image
Dockerfile
Layered image descriptions
11
Debian
Node JS
LDF server
12
# Inherit from the Node 4.2.2 image
FROM node:4.2.2
# Copy the server files
ADD . /app
# Install the node module
RUN cd /app && npm install
# Expose the default port
EXPOSE 3000
# Run base binary
ENTRYPOINT ["node", "bin/ldf-server"]
# Default command
CMD ["--help"]
> cat Dockerfile
RUN Executed when the image is being built
Zero or more RUN’s per Dockerfile
Typically used for installing software
Result will be stored in image
CMD Executed when the image is being run/instantiated
Only one CMD per Dockerfile
Default command to run when starting the container
Can be overridden by user
! Difference between RUN and CMD !
13
Build image to your local repository
Building a Dockerfile to an image
14
> docker build -t <image-name> <path-to-dir>
All your available images
Your local image repository
15
> docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ldf-server latest db3a7fb38cb2 10 minutes ago 683.3 MB
stuff latest do89d002jbsd 1 week ago 102.2 MB
http://hub.docker.com
Reuse existing images
16
Search the Docker hub, and download images to your local repo
Or use the command-line...
17
> docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating s... 4958 [OK]
ubuntu-upstart Upstart is an event-based replacement for ... 67 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 47 [OK]
> docker pull ubuntu
12.04: Pulling from library/ubuntu
ba2b457ecfb2: Pull complete
26180b0fe8fb: Pull complete
edd7c1974a70: Pull complete
57bca5139a13: Pull complete
library/ubuntu:12.04: The image you are pulling has been verified.
Status: Downloaded newer image for ubuntu:12.04
Instantiate an image
Running an image
18
> docker run -it --rm ldf-server
Important options:
-i
-t
--rm
-d
-p 8080:80
-v /mydir:/targetdir
...
Keep STDIN open
Allocate new terminal
Remove container after stopping (default: stopped state)
Run in background
Map host port to container port
Map local directory to container directory
List running containers
List running + stopped containers
Stop container
Remove container
List images
Remove image
Image and container management
19
docker ps
docker ps -a
docker stop <container-hash-or-name>
docker rm <container-hash-or-name>
docker images
docker rmi <image-name>
Attach an image (not guaranteed to have a CLI)
Using detached containers
20
> docker attach <container-hash>
Open shell in container (useful for debugging)
> docker exec -it <container-hash> /bin/bash
CTRL+p CTRL+q to detach
Overview
Basics
Networks
Convenience tools
21
Connect microservices
using virtual Docker networks
22
Docker webserver
NGINX
PostgreSQL
Node
Managing networks
23
> docker network ls
NETWORK ID NAME DRIVER
7fca4eb8c647 bridge bridge
9f904ee27bf5 none null
cf03ee007fb4 host host
Default
Dummy network
Same as host network
> docker network create --driver bridge <network-name>
> docker network inspect <network-name>
> docker run --network=<network-name> <image-name>
using Docker swarm
Swarm
Running containers on multiple hosts
24
Manager
Node 1Node 0 Node 2
Scale applications, by running containers N times
Load balancing
Automatic management
Deploying applications in clusters
25
Scale applications, by running containers N times
Load balancing
Automatic management
Deploying applications in clusters
26
Overview
Basics
Networks
Convenience tools
27
Docker Compose
Declaratively define multi-container applications in docker-compose.yml
28
> docker-compose up -d
> docker-compose stop
> docker-compose rm
29
version: '2'
services:
server:
image: linkeddatafragments/server.js
ports:
- "3000:3000"
volumes:
- ${DATA_DIR}:/data
- ./config-server.json:/tmp/config.json
command: /tmp/config.json 3000 ${LDF_WORKERS}
server-cache:
image: nginx:stable
ports:
- "80:80"
volumes:
- ./nginx-default:/etc/.../default:ro
links:
- server
> cat docker-compose.yml
Docker Machine
Install Docker Engine on any host
Easily SSH to any host to control it
30
Methods for measuring CPU, memory usage, I/O …
Third-party alternatives: Datadog, CAdvisor, Scout ...
Monitoring
31
> docker stats
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O
1285939c1fd3 0.07% 796 KiB / 64 MiB 1.21% 788 B / 648 B 3.568 MB / 512 KB
9c76f7834ae2 0.07% 2.746 MiB / 64 MiB 4.29% 1.266 KB / 648 B 12.4 MB / 0 B
d1ea048f04e4 0.03% 4.583 MiB / 64 MiB 6.30% 2.854 KB / 648 B 27.7 MB / 0 B
Overview
Basics
Networks
Convenience tools
32

Más contenido relacionado

La actualidad más candente

2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and Docker
Fabio Fumarola
 
Docker - container and lightweight virtualization
Docker - container and lightweight virtualization Docker - container and lightweight virtualization
Docker - container and lightweight virtualization
Sim Janghoon
 
Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7
Etsuji Nakai
 

La actualidad más candente (20)

A Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things ContainersA Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things Containers
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker internals
Docker internalsDocker internals
Docker internals
 
Docker DANS workshop
Docker DANS workshopDocker DANS workshop
Docker DANS workshop
 
2 Linux Container and Docker
2 Linux Container and Docker2 Linux Container and Docker
2 Linux Container and Docker
 
An Introduction to Kubernetes
An Introduction to KubernetesAn Introduction to Kubernetes
An Introduction to Kubernetes
 
Docker / Ansible
Docker / AnsibleDocker / Ansible
Docker / Ansible
 
Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)Networking and Go: An Engineer's Journey (Strangeloop 2019)
Networking and Go: An Engineer's Journey (Strangeloop 2019)
 
Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubern...
Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubern...Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubern...
Endocode Kubernetes Meetup: Architecture Patterns for Microservices in Kubern...
 
Breaking the RpiDocker challenge
Breaking the RpiDocker challenge Breaking the RpiDocker challenge
Breaking the RpiDocker challenge
 
Docker n co
Docker n coDocker n co
Docker n co
 
Shifter: Containers in HPC Environments
Shifter: Containers in HPC EnvironmentsShifter: Containers in HPC Environments
Shifter: Containers in HPC Environments
 
Docker - container and lightweight virtualization
Docker - container and lightweight virtualization Docker - container and lightweight virtualization
Docker - container and lightweight virtualization
 
Container Orchestration from Theory to Practice
Container Orchestration from Theory to PracticeContainer Orchestration from Theory to Practice
Container Orchestration from Theory to Practice
 
Docker volume
Docker volumeDocker volume
Docker volume
 
Red Teaming macOS Environments with Hermes the Swift Messenger
Red Teaming macOS Environments with Hermes the Swift MessengerRed Teaming macOS Environments with Hermes the Swift Messenger
Red Teaming macOS Environments with Hermes the Swift Messenger
 
Docker
DockerDocker
Docker
 
Demystifying kubernetes
Demystifying kubernetesDemystifying kubernetes
Demystifying kubernetes
 
Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7Inside Docker for Fedora20/RHEL7
Inside Docker for Fedora20/RHEL7
 
Kubernetes the deltatre way the basics - introduction to containers and orc...
Kubernetes the deltatre way   the basics - introduction to containers and orc...Kubernetes the deltatre way   the basics - introduction to containers and orc...
Kubernetes the deltatre way the basics - introduction to containers and orc...
 

Destacado

PowerPoint Presentation.2015
PowerPoint Presentation.2015PowerPoint Presentation.2015
PowerPoint Presentation.2015
Samar Kamel
 
Kent English Profile
Kent English ProfileKent English Profile
Kent English Profile
Rex Kent Liu
 
Tienda motor store
Tienda motor storeTienda motor store
Tienda motor store
Amaiitaa
 

Destacado (18)

Jelly Shots
Jelly ShotsJelly Shots
Jelly Shots
 
EKAW - Triple Pattern Fragments
EKAW - Triple Pattern FragmentsEKAW - Triple Pattern Fragments
EKAW - Triple Pattern Fragments
 
Continuous Self-Updating Query Results over Dynamic Linked Data
Continuous Self-Updating Query Results over Dynamic Linked DataContinuous Self-Updating Query Results over Dynamic Linked Data
Continuous Self-Updating Query Results over Dynamic Linked Data
 
Continuously Updating Query Results over Real-Time Linked Data
Continuously Updating Query Results over Real-Time Linked DataContinuously Updating Query Results over Real-Time Linked Data
Continuously Updating Query Results over Real-Time Linked Data
 
EKAW - Linked Data Publishing
EKAW - Linked Data PublishingEKAW - Linked Data Publishing
EKAW - Linked Data Publishing
 
PowerPoint Presentation.2015
PowerPoint Presentation.2015PowerPoint Presentation.2015
PowerPoint Presentation.2015
 
Abhishek
AbhishekAbhishek
Abhishek
 
The Demon Final
The Demon FinalThe Demon Final
The Demon Final
 
Kent English Profile
Kent English ProfileKent English Profile
Kent English Profile
 
Tienda motor store
Tienda motor storeTienda motor store
Tienda motor store
 
Camera Angles
Camera AnglesCamera Angles
Camera Angles
 
Docker Demystified - Virtual VMs without the Fat
Docker Demystified - Virtual VMs without the FatDocker Demystified - Virtual VMs without the Fat
Docker Demystified - Virtual VMs without the Fat
 
Penguat transistor
Penguat transistorPenguat transistor
Penguat transistor
 
Nome - logo book
Nome  - logo bookNome  - logo book
Nome - logo book
 
Working with kubernetes
Working with kubernetesWorking with kubernetes
Working with kubernetes
 
Docker from basics to orchestration (PHPConfBr2015)
Docker from basics to orchestration (PHPConfBr2015)Docker from basics to orchestration (PHPConfBr2015)
Docker from basics to orchestration (PHPConfBr2015)
 
Flower lamp
Flower lampFlower lamp
Flower lamp
 
Trade commodity finance and its services
Trade commodity finance and its servicesTrade commodity finance and its services
Trade commodity finance and its services
 

Similar a Docker Intro

Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
nigamsajal14
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
Balaji Rajan
 

Similar a Docker Intro (20)

Powercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptxPowercoders · Docker · Fall 2021.pptx
Powercoders · Docker · Fall 2021.pptx
 
Introducing Docker
Introducing DockerIntroducing Docker
Introducing Docker
 
How to _docker
How to _dockerHow to _docker
How to _docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak PeekDocker for Web Developers: A Sneak Peek
Docker for Web Developers: A Sneak Peek
 
Docking with Docker
Docking with DockerDocking with Docker
Docking with Docker
 
Docker
DockerDocker
Docker
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Docker+java
Docker+javaDocker+java
Docker+java
 
Lecture eight to be introduced in class.
Lecture eight to be introduced in class.Lecture eight to be introduced in class.
Lecture eight to be introduced in class.
 
docker.pdf
docker.pdfdocker.pdf
docker.pdf
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
 
The Docker Ecosystem
The Docker EcosystemThe Docker Ecosystem
The Docker Ecosystem
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
 
Introduction of Docker and Docker Compose
Introduction of Docker and Docker ComposeIntroduction of Docker and Docker Compose
Introduction of Docker and Docker Compose
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Docker HK Meetup - 201707
Docker HK Meetup - 201707Docker HK Meetup - 201707
Docker HK Meetup - 201707
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Development
 
廣宣學堂: 容器進階實務 - Docker進深研究班
廣宣學堂: 容器進階實務 - Docker進深研究班廣宣學堂: 容器進階實務 - Docker進深研究班
廣宣學堂: 容器進階實務 - Docker進深研究班
 

Más de Ruben Taelman

Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...
Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...
Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...
Ruben Taelman
 
Poster Declaratively Describing Responses of Hypermedia-Driven Web APIs
Poster Declaratively Describing Responses of Hypermedia-Driven Web APIsPoster Declaratively Describing Responses of Hypermedia-Driven Web APIs
Poster Declaratively Describing Responses of Hypermedia-Driven Web APIs
Ruben Taelman
 
PoDiGG: Public Transport Dataset Generator based on Population Distributions
PoDiGG: Public Transport Dataset Generator based on Population DistributionsPoDiGG: Public Transport Dataset Generator based on Population Distributions
PoDiGG: Public Transport Dataset Generator based on Population Distributions
Ruben Taelman
 
Querying Dynamic Datasources with Continuously Mapped Sensor Data
Querying Dynamic Datasources with Continuously Mapped Sensor DataQuerying Dynamic Datasources with Continuously Mapped Sensor Data
Querying Dynamic Datasources with Continuously Mapped Sensor Data
Ruben Taelman
 

Más de Ruben Taelman (13)

Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...
Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...
Poster Demonstration of Comunica, a Web framework for querying heterogeneous ...
 
Poster GraphQL-LD: Linked Data Querying with GraphQL
Poster GraphQL-LD: Linked Data Querying with GraphQLPoster GraphQL-LD: Linked Data Querying with GraphQL
Poster GraphQL-LD: Linked Data Querying with GraphQL
 
Poster Declaratively Describing Responses of Hypermedia-Driven Web APIs
Poster Declaratively Describing Responses of Hypermedia-Driven Web APIsPoster Declaratively Describing Responses of Hypermedia-Driven Web APIs
Poster Declaratively Describing Responses of Hypermedia-Driven Web APIs
 
Components.js
Components.jsComponents.js
Components.js
 
Versioned Triple Pattern Fragments
Versioned Triple Pattern FragmentsVersioned Triple Pattern Fragments
Versioned Triple Pattern Fragments
 
Versioned Triple Pattern Fragments
Versioned Triple Pattern FragmentsVersioned Triple Pattern Fragments
Versioned Triple Pattern Fragments
 
PoDiGG: Public Transport Dataset Generator based on Population Distributions
PoDiGG: Public Transport Dataset Generator based on Population DistributionsPoDiGG: Public Transport Dataset Generator based on Population Distributions
PoDiGG: Public Transport Dataset Generator based on Population Distributions
 
Exposing RDF Archives using Triple Pattern Fragments
Exposing RDF Archives using Triple Pattern FragmentsExposing RDF Archives using Triple Pattern Fragments
Exposing RDF Archives using Triple Pattern Fragments
 
EKAW - Publishing with Triple Pattern Fragments
EKAW - Publishing with Triple Pattern FragmentsEKAW - Publishing with Triple Pattern Fragments
EKAW - Publishing with Triple Pattern Fragments
 
Multidimensional Interfaces for Selecting Data with Order
Multidimensional Interfaces for Selecting Data with OrderMultidimensional Interfaces for Selecting Data with Order
Multidimensional Interfaces for Selecting Data with Order
 
Scalable Dynamic Data Consumption on the Web
Scalable Dynamic Data Consumption on the WebScalable Dynamic Data Consumption on the Web
Scalable Dynamic Data Consumption on the Web
 
Moving RDF Stream Processing to the Client
Moving RDF Stream Processing to the ClientMoving RDF Stream Processing to the Client
Moving RDF Stream Processing to the Client
 
Querying Dynamic Datasources with Continuously Mapped Sensor Data
Querying Dynamic Datasources with Continuously Mapped Sensor DataQuerying Dynamic Datasources with Continuously Mapped Sensor Data
Querying Dynamic Datasources with Continuously Mapped Sensor Data
 

Último

Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Último (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Docker Intro

  • 1. An Introduction to Docker 1 Ruben Taelman - @rubensworks imec - Ghent University
  • 2. So what is Docker? Platform for running software in isolated containers 2
  • 3. So what is Docker? Platform for running software in isolated containers 3 Traditional webserver NGINX PostgreSQL Node
  • 4. So what is Docker? Platform for running software in isolated containers 4 Traditional webserver Docker webserver NGINX PostgreSQL Node NGINX PostgreSQL Node
  • 5. So what is Docker? Platform for running software in isolated containers 5 Traditional webserver Docker webserver NGINX PostgreSQL Node NGINX PostgreSQL Node ✓Linux ✓Windows ✓Mac
  • 6. (Reproducible) software evaluations Easily installable and disposable software Running different software versions simultaneously What to use Docker for? 6
  • 9. Virtual machines vs containers (Docker) containers don’t need separate OS’s, so they are more lightweight. 9
  • 10. Docker workflow 10 Dockerfile Image Container Build Run Description of an image Built image Available for reuse Instantiated image
  • 12. 12 # Inherit from the Node 4.2.2 image FROM node:4.2.2 # Copy the server files ADD . /app # Install the node module RUN cd /app && npm install # Expose the default port EXPOSE 3000 # Run base binary ENTRYPOINT ["node", "bin/ldf-server"] # Default command CMD ["--help"] > cat Dockerfile
  • 13. RUN Executed when the image is being built Zero or more RUN’s per Dockerfile Typically used for installing software Result will be stored in image CMD Executed when the image is being run/instantiated Only one CMD per Dockerfile Default command to run when starting the container Can be overridden by user ! Difference between RUN and CMD ! 13
  • 14. Build image to your local repository Building a Dockerfile to an image 14 > docker build -t <image-name> <path-to-dir>
  • 15. All your available images Your local image repository 15 > docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ldf-server latest db3a7fb38cb2 10 minutes ago 683.3 MB stuff latest do89d002jbsd 1 week ago 102.2 MB
  • 17. Search the Docker hub, and download images to your local repo Or use the command-line... 17 > docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating s... 4958 [OK] ubuntu-upstart Upstart is an event-based replacement for ... 67 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 47 [OK] > docker pull ubuntu 12.04: Pulling from library/ubuntu ba2b457ecfb2: Pull complete 26180b0fe8fb: Pull complete edd7c1974a70: Pull complete 57bca5139a13: Pull complete library/ubuntu:12.04: The image you are pulling has been verified. Status: Downloaded newer image for ubuntu:12.04
  • 18. Instantiate an image Running an image 18 > docker run -it --rm ldf-server Important options: -i -t --rm -d -p 8080:80 -v /mydir:/targetdir ... Keep STDIN open Allocate new terminal Remove container after stopping (default: stopped state) Run in background Map host port to container port Map local directory to container directory
  • 19. List running containers List running + stopped containers Stop container Remove container List images Remove image Image and container management 19 docker ps docker ps -a docker stop <container-hash-or-name> docker rm <container-hash-or-name> docker images docker rmi <image-name>
  • 20. Attach an image (not guaranteed to have a CLI) Using detached containers 20 > docker attach <container-hash> Open shell in container (useful for debugging) > docker exec -it <container-hash> /bin/bash CTRL+p CTRL+q to detach
  • 22. Connect microservices using virtual Docker networks 22 Docker webserver NGINX PostgreSQL Node
  • 23. Managing networks 23 > docker network ls NETWORK ID NAME DRIVER 7fca4eb8c647 bridge bridge 9f904ee27bf5 none null cf03ee007fb4 host host Default Dummy network Same as host network > docker network create --driver bridge <network-name> > docker network inspect <network-name> > docker run --network=<network-name> <image-name>
  • 24. using Docker swarm Swarm Running containers on multiple hosts 24 Manager Node 1Node 0 Node 2
  • 25. Scale applications, by running containers N times Load balancing Automatic management Deploying applications in clusters 25
  • 26. Scale applications, by running containers N times Load balancing Automatic management Deploying applications in clusters 26
  • 28. Docker Compose Declaratively define multi-container applications in docker-compose.yml 28 > docker-compose up -d > docker-compose stop > docker-compose rm
  • 29. 29 version: '2' services: server: image: linkeddatafragments/server.js ports: - "3000:3000" volumes: - ${DATA_DIR}:/data - ./config-server.json:/tmp/config.json command: /tmp/config.json 3000 ${LDF_WORKERS} server-cache: image: nginx:stable ports: - "80:80" volumes: - ./nginx-default:/etc/.../default:ro links: - server > cat docker-compose.yml
  • 30. Docker Machine Install Docker Engine on any host Easily SSH to any host to control it 30
  • 31. Methods for measuring CPU, memory usage, I/O … Third-party alternatives: Datadog, CAdvisor, Scout ... Monitoring 31 > docker stats CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O 1285939c1fd3 0.07% 796 KiB / 64 MiB 1.21% 788 B / 648 B 3.568 MB / 512 KB 9c76f7834ae2 0.07% 2.746 MiB / 64 MiB 4.29% 1.266 KB / 648 B 12.4 MB / 0 B d1ea048f04e4 0.03% 4.583 MiB / 64 MiB 6.30% 2.854 KB / 648 B 27.7 MB / 0 B