SlideShare a Scribd company logo
Docker
What is Docker?
Duckietown
I got it, it is like VirtualBox…. Hem, not really!
3
• Docker is similar (in spirit) to Virtual Environments but at a File System level
VM 1 VM 2 VM 3
Container1 Container2 Container3
Why Docker?
Duckietown
Common scenario
• You just started a new research project
1. Freshly install Ubuntu for a clean environment
2. Configure your environment
3. Install all the libraries you need
5
ubuntu:18.04
NAME=Andrea
apt install python-numpy
#
>
>
Duckietown
Common scenario (with Docker)
• You just started a new research project
1. Freshly install Ubuntu for a clean environment
2. Configure your environment
3. Install all the libraries you need
6
ubuntu:18.04
NAME=Andrea
apt install python-numpy
FROM
ENV
RUN
Docker2ile
Duckietown
Docker = A lot of new confusing terms…
7
For example:
• Docker Layer
• Docker Image
• Docker Container
• Docker Volume
• Docker Registry
• Docker Compose
Docker
Layer/Image/File
Duckietown
Docker Layer
• It is a collection of files
• e.g.,
/my_file.dat (user file)
/etc/hosts (system file)
• It is uniquely identified by an hash
sha256:94c5c6f50a7204b49c5cdfd662aa203f3af0b2e2eb6b449634738edfae77fbe3
9
Duckietown
Docker Image
• It is the combination of a sequence of Docker Layers
• It is uniquely identified by an hash
sha256:3448a24e6db0125ebbafefee0a355232fc533bd3a68c89dab3d450a8fa15d8ed
• It is also (non-uniquely) identified by a name
library/ubuntu:18.04
afdaniele/compose:0.9
format:
[owner] / [image] : [tag]
library / [image] : latest (default)
10
Duckietown
Docker Image VS Docker Layers
• You CANNOT create single layers
• You CAN create new images
• Layers are read-only
• The simplest (most beautiful) way to create an image is a Dockerfile
11
Duckietown
Dockerfile (an example)
12
FROM python:3.6
MAINTAINER Andrea F. Daniele <afdaniele@ttic.edu>
RUN pip3 install tensorflow
VOLUME /tflog
EXPOSE 6006/tcp
CMD ["python3", "-m", “tensorflow.tensorboard", "--logdir=/tflog"]
Duckietown
Dockerfile - Instructions
13
FROM
ARG
ENV
MAINTAINER
WORKDIR
USER
RUN
ADD
COPY
VOLUME
EXPOSE
CMD
ENTRYPOINT
Define the base image
Define build-only arguments (non-persistent)
Define environment variables (persistent)
Set maintainer info
Set working directory
Set user ID
Run a command inside a container
Copy files and directories from the build context
Copy files and directories from the build context
Define a new volume
Declare ports used by the image
Define default command
Define entrypoint executable
Useful documentation: docs.docker.com/reference
Duckietown
Docker Image
14
FROM python:3.6
MAINTAINER Andrea F. Daniele <afdaniele@ttic.edu>
RUN pip3 install tensorflow
VOLUME /tflog
...
EXPOSE 6006/tcp
CMD ["python3", "-m", “tensorflow.tensorboard", "--logdir=/tflog"]
Docker'ile
python : 3.6
afdaniele / tensor2low
intermediate layers
Building an Image
Duckietown
Directory
Build Context
16
FROM python:3.6
...
COPY my_image.jpg /data/my_image.jpg
...
Docker'ile
• A directory from which Docker is allowed to copy files to a layer
Duckietown
Building a Docker Image (using Dockerfile)
• Build an image from a Dockerfile and a Build Context
17
docker build -t my_image [-f Dockerfile] ./
>
Image name Docker2ile path Build context
Docker'il
e
Build context
Docker Engine Docker Image
Docker Container
Duckietown
Docker Container
• An instance of a Docker image
• It is uniquely identified by an alphanumeric string. e.g.,
94c5c6f50a7204b49c5cdfd662aa203f3af0b2e2eb6b449634738edfae77fbe3
• It is also assigned a (possibly custom) name. e.g.,
admiring_einstein
my_website
19
docker run [options] my_image
>
• Run a container from an image
Image name
Duckietown
Docker Container
20
python : 3.6
afdaniele / tensor2low
volatile (writeable) layer
docker run [options] my_image
>
• Run a container from an image
Image name
• Contains everything you do in a running container
• Is lost when the container is deleted
Duckietown
Combining layers - AUFS FileSystem
Advanced multi-layered Unification File System
21
Another Unification File System
• Later revised to,
• Originally meaning,
Data Persistency
Duckietown
Data persistency - Mounting directories
• You can share local directories with one or more containers using
where,
path to a directory in the host file system
destination path to the directory in the container file system
23
docker run -v [local_dir]:[container_dir] my_image
>
local_dir
container_dir
Duckietown
Data persistency - Docker Volumes
• Create a Docker volume
• You can attach a volume to a container using
where,
name of the volume
destination path in the container file system
24
docker volume create [volume_name]
>
volume_name
container_dir
docker run -v [volume_name]:[container_dir] my_image
>
Duckietown
Docker Container (an interesting one)
• Running the Dashboard on a Duckiebot
25
docker run 
-it 
-p 8080:80/tcp 
-v compose-data:/var/www/html 
-v /data:/data 
--hostname $(hostname) 
--name dashboard 
duckietown/dt-duckiebot-dashboard:daffy
>
docker volume create compose-data
>
Duckietown
Dockerfile, Docker Image and Docker Container
26
Docker Registry
Duckietown
Docker Registry
• A storage and distribution system for Docker images
• Two fundamental operations: push and pull
28
Docker Compose
Duckietown
80 / tcp
backups
db-storage
mysql-db
web-server
version: '2'
services:
mysql-db:
image: mysql:latest
volumes:
- db-storage:/var/lib/mysql
- backups:/backups
web-server:
image: apache:latest
ports:
- "80:80"
links:
- mysql-db:mysql.db
environment:
- DBHost=mysql.db
- DBUser=my_user
- DBPassword=my_password
volumes:
db-storage:
backups:
docker-compose.yaml
Docker Compose
• An application can be split across multiple Docker images
• The application runs when all the corresponding containers run
Docker in Duckietown
Duckietown 32
Duckietown
The Docker images family tree
Duckietown
Duckiebot Pipeline
33
Duckietown
Duckiebot Pipeline
34
dt-duckiebot-interface
• left/right wheel speed
• raw camera image
• leds color and pattern
Duckietown
Duckiebot Pipeline
35
dt-duckiebot-interface
• left/right wheel speed
• raw camera image
• led color and pattern
dt-car-interface
• linear/angular velocity
Duckietown
Duckiebot Pipeline
36
dt-duckiebot-interface
• left/right wheel speed
• raw camera image
• led color and pattern
dt-car-interface
• linear/angular velocity
dt-core
• lane following
• coordination
• …
Duckietown
What’s nice about Docker
• Dockerfiles serve as (required) documentation
• Full control over execution environment
• Know exactly what the dependencies are (e.g., dependencies-apt.txt)
• Know exactly what files your application needs (build context, docker diff)
• Full support of cross-application interaction
• e.g., ROS, LCM
• No conflict between libraries
• Full control over networks and ports
• Open only the ports and for the protocols you need
• Full control over resources (X-Server, CPU, GPU, RAM)
37

More Related Content

PPTX
Docker and the Container Ecosystem
PDF
Docker Essentials Workshop— Innovation Labs July 2020
PDF
Docker 101 - Intro to Docker
PDF
Docker as an every day work tool
PPTX
Getting Started With Docker: Simplifying DevOps
PDF
Introduction to Docker
PDF
Docker by Example - Basics
PDF
Docker
Docker and the Container Ecosystem
Docker Essentials Workshop— Innovation Labs July 2020
Docker 101 - Intro to Docker
Docker as an every day work tool
Getting Started With Docker: Simplifying DevOps
Introduction to Docker
Docker by Example - Basics
Docker

Similar to Dockers Containers in action Slide 0 to hero (20)

PDF
Containers + Docker workshop - part 2
PDF
Introduction to docker
PPTX
Containerization using docker and its applications
PPTX
Containerization using docker and its applications
PDF
Learning Docker with Thomas
PDF
Victor Vieux at Docker Paris Meetup #1
PDF
Docker presentation | Paris Docker Meetup
PPTX
Docker for dev
PDF
Dockers & kubernetes detailed - Beginners to Geek
PPTX
PDF
Docker 101 Workshop slides (JavaOne 2017)
ODP
Docker Basics
PDF
Talk about Docker
PDF
Docker, but what it is?
PDF
A Hands-on Introduction to Docker
PDF
Introduction to Docker
PDF
Docker for Deep Learning (Andrea Panizza)
PPT
14309525_docker_docker_docker_docker_introduction.ppt
PDF
Check the version with fixes. Link in description
PPTX
Docker Introductory workshop
Containers + Docker workshop - part 2
Introduction to docker
Containerization using docker and its applications
Containerization using docker and its applications
Learning Docker with Thomas
Victor Vieux at Docker Paris Meetup #1
Docker presentation | Paris Docker Meetup
Docker for dev
Dockers & kubernetes detailed - Beginners to Geek
Docker 101 Workshop slides (JavaOne 2017)
Docker Basics
Talk about Docker
Docker, but what it is?
A Hands-on Introduction to Docker
Introduction to Docker
Docker for Deep Learning (Andrea Panizza)
14309525_docker_docker_docker_docker_introduction.ppt
Check the version with fixes. Link in description
Docker Introductory workshop
Ad

Recently uploaded (20)

PPTX
Introduction to pro and eukaryotes and differences.pptx
PPTX
20th Century Theater, Methods, History.pptx
PPTX
Introduction to Building Materials
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Trump Administration's workforce development strategy
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
Empowerment Technology for Senior High School Guide
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
My India Quiz Book_20210205121199924.pdf
PDF
HVAC Specification 2024 according to central public works department
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
Hazard Identification & Risk Assessment .pdf
Introduction to pro and eukaryotes and differences.pptx
20th Century Theater, Methods, History.pptx
Introduction to Building Materials
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Trump Administration's workforce development strategy
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Empowerment Technology for Senior High School Guide
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Weekly quiz Compilation Jan -July 25.pdf
Share_Module_2_Power_conflict_and_negotiation.pptx
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
My India Quiz Book_20210205121199924.pdf
HVAC Specification 2024 according to central public works department
B.Sc. DS Unit 2 Software Engineering.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Hazard Identification & Risk Assessment .pdf
Ad

Dockers Containers in action Slide 0 to hero

  • 3. Duckietown I got it, it is like VirtualBox…. Hem, not really! 3 • Docker is similar (in spirit) to Virtual Environments but at a File System level VM 1 VM 2 VM 3 Container1 Container2 Container3
  • 5. Duckietown Common scenario • You just started a new research project 1. Freshly install Ubuntu for a clean environment 2. Configure your environment 3. Install all the libraries you need 5 ubuntu:18.04 NAME=Andrea apt install python-numpy # > >
  • 6. Duckietown Common scenario (with Docker) • You just started a new research project 1. Freshly install Ubuntu for a clean environment 2. Configure your environment 3. Install all the libraries you need 6 ubuntu:18.04 NAME=Andrea apt install python-numpy FROM ENV RUN Docker2ile
  • 7. Duckietown Docker = A lot of new confusing terms… 7 For example: • Docker Layer • Docker Image • Docker Container • Docker Volume • Docker Registry • Docker Compose
  • 9. Duckietown Docker Layer • It is a collection of files • e.g., /my_file.dat (user file) /etc/hosts (system file) • It is uniquely identified by an hash sha256:94c5c6f50a7204b49c5cdfd662aa203f3af0b2e2eb6b449634738edfae77fbe3 9
  • 10. Duckietown Docker Image • It is the combination of a sequence of Docker Layers • It is uniquely identified by an hash sha256:3448a24e6db0125ebbafefee0a355232fc533bd3a68c89dab3d450a8fa15d8ed • It is also (non-uniquely) identified by a name library/ubuntu:18.04 afdaniele/compose:0.9 format: [owner] / [image] : [tag] library / [image] : latest (default) 10
  • 11. Duckietown Docker Image VS Docker Layers • You CANNOT create single layers • You CAN create new images • Layers are read-only • The simplest (most beautiful) way to create an image is a Dockerfile 11
  • 12. Duckietown Dockerfile (an example) 12 FROM python:3.6 MAINTAINER Andrea F. Daniele <afdaniele@ttic.edu> RUN pip3 install tensorflow VOLUME /tflog EXPOSE 6006/tcp CMD ["python3", "-m", “tensorflow.tensorboard", "--logdir=/tflog"]
  • 13. Duckietown Dockerfile - Instructions 13 FROM ARG ENV MAINTAINER WORKDIR USER RUN ADD COPY VOLUME EXPOSE CMD ENTRYPOINT Define the base image Define build-only arguments (non-persistent) Define environment variables (persistent) Set maintainer info Set working directory Set user ID Run a command inside a container Copy files and directories from the build context Copy files and directories from the build context Define a new volume Declare ports used by the image Define default command Define entrypoint executable Useful documentation: docs.docker.com/reference
  • 14. Duckietown Docker Image 14 FROM python:3.6 MAINTAINER Andrea F. Daniele <afdaniele@ttic.edu> RUN pip3 install tensorflow VOLUME /tflog ... EXPOSE 6006/tcp CMD ["python3", "-m", “tensorflow.tensorboard", "--logdir=/tflog"] Docker'ile python : 3.6 afdaniele / tensor2low intermediate layers
  • 16. Duckietown Directory Build Context 16 FROM python:3.6 ... COPY my_image.jpg /data/my_image.jpg ... Docker'ile • A directory from which Docker is allowed to copy files to a layer
  • 17. Duckietown Building a Docker Image (using Dockerfile) • Build an image from a Dockerfile and a Build Context 17 docker build -t my_image [-f Dockerfile] ./ > Image name Docker2ile path Build context Docker'il e Build context Docker Engine Docker Image
  • 19. Duckietown Docker Container • An instance of a Docker image • It is uniquely identified by an alphanumeric string. e.g., 94c5c6f50a7204b49c5cdfd662aa203f3af0b2e2eb6b449634738edfae77fbe3 • It is also assigned a (possibly custom) name. e.g., admiring_einstein my_website 19 docker run [options] my_image > • Run a container from an image Image name
  • 20. Duckietown Docker Container 20 python : 3.6 afdaniele / tensor2low volatile (writeable) layer docker run [options] my_image > • Run a container from an image Image name • Contains everything you do in a running container • Is lost when the container is deleted
  • 21. Duckietown Combining layers - AUFS FileSystem Advanced multi-layered Unification File System 21 Another Unification File System • Later revised to, • Originally meaning,
  • 23. Duckietown Data persistency - Mounting directories • You can share local directories with one or more containers using where, path to a directory in the host file system destination path to the directory in the container file system 23 docker run -v [local_dir]:[container_dir] my_image > local_dir container_dir
  • 24. Duckietown Data persistency - Docker Volumes • Create a Docker volume • You can attach a volume to a container using where, name of the volume destination path in the container file system 24 docker volume create [volume_name] > volume_name container_dir docker run -v [volume_name]:[container_dir] my_image >
  • 25. Duckietown Docker Container (an interesting one) • Running the Dashboard on a Duckiebot 25 docker run -it -p 8080:80/tcp -v compose-data:/var/www/html -v /data:/data --hostname $(hostname) --name dashboard duckietown/dt-duckiebot-dashboard:daffy > docker volume create compose-data >
  • 26. Duckietown Dockerfile, Docker Image and Docker Container 26
  • 28. Duckietown Docker Registry • A storage and distribution system for Docker images • Two fundamental operations: push and pull 28
  • 30. Duckietown 80 / tcp backups db-storage mysql-db web-server version: '2' services: mysql-db: image: mysql:latest volumes: - db-storage:/var/lib/mysql - backups:/backups web-server: image: apache:latest ports: - "80:80" links: - mysql-db:mysql.db environment: - DBHost=mysql.db - DBUser=my_user - DBPassword=my_password volumes: db-storage: backups: docker-compose.yaml Docker Compose • An application can be split across multiple Docker images • The application runs when all the corresponding containers run
  • 34. Duckietown Duckiebot Pipeline 34 dt-duckiebot-interface • left/right wheel speed • raw camera image • leds color and pattern
  • 35. Duckietown Duckiebot Pipeline 35 dt-duckiebot-interface • left/right wheel speed • raw camera image • led color and pattern dt-car-interface • linear/angular velocity
  • 36. Duckietown Duckiebot Pipeline 36 dt-duckiebot-interface • left/right wheel speed • raw camera image • led color and pattern dt-car-interface • linear/angular velocity dt-core • lane following • coordination • …
  • 37. Duckietown What’s nice about Docker • Dockerfiles serve as (required) documentation • Full control over execution environment • Know exactly what the dependencies are (e.g., dependencies-apt.txt) • Know exactly what files your application needs (build context, docker diff) • Full support of cross-application interaction • e.g., ROS, LCM • No conflict between libraries • Full control over networks and ports • Open only the ports and for the protocols you need • Full control over resources (X-Server, CPU, GPU, RAM) 37