SlideShare a Scribd company logo
Docker Hands-On
Dharmit Shah
@dharm1t
Who am I?
(Earlier)
@
@
Agenda
Talk
➔ Understanding the Docker terminology
➔ What is a layer?
➔ What are Docker images?
Hands-on
➔ Creating a container
➔ Creating a docker image
➔ Dockerfile
➔ Using nsenter
What is a Layer?
➔ In traditional Linux, kernel mounts the root file system as read-only and later
switches to read-write mode
➔ When Docker mounts the root, it starts read-only
➔ Later, instead of turning to read-write mode, it adds read-write file system over
the read-only file system
➔ There could be multiple read-only file systems stacked on top of each other
➔ Each of this file system is called as layer
What is a layer (contd..)
➔ Any time a process creates a file, this happens in top layer.
➔ If some file from lower layer needs to be updated, it first gets copied to top layer.
➔ Changes go into the copy
➔ Version of file on lower layer remains unchanged but cannot be seen by
applications
➔ Union File System - union of read-write and all read-only layers
What is a Layer? (contd.)
What are Docker images?
➔ In Docker, a read-only layer is called in Image
➔ An image never changes
➔ Each image depends on one more image which forms the layer beneath it
➔ This lower image is sometimes referred to as Parent Image
➔ An image that has no parent image is called Base Image
What are Docker images? (contd.)
What are Docker images? (contd.)
Creating a container
$ sudo docker pull ubuntu:14.10
$ sudo docker run -ti ubuntu:14.10 /bin/bash
$ ip a
$ hostname
$ uname -a
Creating an image
➔ We will create a minimal image from the container we created in previous step
$ sudo docker ps
$ sudo docker ps -a
$ man docker-commit
$ sudo docker commit <container-id> -t <repository>/<tag>
$ sudo docker tag <image> <tag>
What is a Dockerfile?
➔ Automates building images
➔ A text document that contains commands to build an image
➔ Parsed by command docker buildto start image creation process
➔ Clone below repo:
$ git clone https://github.com/dharmit/docker_ahmedabad_meetup_2/
➔ Examine the Dockerfile
What is a Dockerfile? (contd..)
➔ FROM python:3.4
➔ WORKDIR /code
➔ ADD django_code /code
➔ RUN pip3 install -r requirements.txt
➔ CMD python3 manage.py runserver 0.0.0.0:8000
Let’s build!
➔ $ sudo docker build -t docker_ahmedabad .
➔ $ sudo docker images
➔ $ sudo docker run -d -p 80:8000 docker_ahmedabad
➔ $ sudo docker ps
➔ In the browser, navigate to 127.0.0.1
If it didn’t work for you
nsenter
➔ Data backup
➔ Check logs
➔ Restart a service
➔ Edit configuration
➔ Debugging
SSH
nsenter (contd..)
➔ Provided by your distro’s util-linux package
➔ How to use it:
$ PID=$(sudo docker inspect --format {{.State.Pid}}
<container_name_or_ID>)
$ nsenter --target $PID --mount --uts --ipc --net --pid /bin/bash
➔ Specify /bin/bash if you’re using a different shell
Image and content credits
➔ http://docker.com
➔ http://redhat.com
➔ http://auberginesolutions.com
Questions?

More Related Content

What's hot (20)

PPTX
Dockerfile Basics | Docker workshop #2 at twitter, 2013-11-05
dotCloud
 
PDF
Docker 原理與實作
kao kuo-tung
 
PPTX
Docker Ecosystem: Part III - Machine
Mario IC
 
PDF
Talk about Docker
Meng-Ze Lee
 
PDF
CoreOS Overview
Victor S. Recio
 
PDF
Docker for developers
Anvay Patil
 
PDF
Infrastructure Deployment with Docker & Ansible
Robert Reiz
 
PPTX
Docker Introduction
Jannis Kirschner
 
PDF
Containerize! Between Docker and Jube.
Henryk Konsek
 
PDF
Docker for mere mortals
Henryk Konsek
 
PDF
Introduction to docker
Wei-Ting Kuo
 
PPTX
Docker Ecosystem: Part V - Docker Registry
Mario IC
 
PPTX
Docker lightning
roadster43
 
PDF
Docker & FieldAware
Jakub Jarosz
 
ODP
Docker and stuff
Raimondas Rimkevičius
 
PDF
The state of the swarm
Mathieu Buffenoir
 
PDF
Intro to Docker - London meetup oct. 2013
stevedomin
 
PDF
Docker Intro
Arnon Rotem-Gal-Oz
 
PDF
Docker & JVM: A Perfect Match
Matthias Grüter
 
PDF
Docker intro
Frei Zhang
 
Dockerfile Basics | Docker workshop #2 at twitter, 2013-11-05
dotCloud
 
Docker 原理與實作
kao kuo-tung
 
Docker Ecosystem: Part III - Machine
Mario IC
 
Talk about Docker
Meng-Ze Lee
 
CoreOS Overview
Victor S. Recio
 
Docker for developers
Anvay Patil
 
Infrastructure Deployment with Docker & Ansible
Robert Reiz
 
Docker Introduction
Jannis Kirschner
 
Containerize! Between Docker and Jube.
Henryk Konsek
 
Docker for mere mortals
Henryk Konsek
 
Introduction to docker
Wei-Ting Kuo
 
Docker Ecosystem: Part V - Docker Registry
Mario IC
 
Docker lightning
roadster43
 
Docker & FieldAware
Jakub Jarosz
 
Docker and stuff
Raimondas Rimkevičius
 
The state of the swarm
Mathieu Buffenoir
 
Intro to Docker - London meetup oct. 2013
stevedomin
 
Docker Intro
Arnon Rotem-Gal-Oz
 
Docker & JVM: A Perfect Match
Matthias Grüter
 
Docker intro
Frei Zhang
 

Similar to Docker hands-on (20)

PDF
A Hands-on Introduction to Docker
CodeOps Technologies LLP
 
PDF
Docker by Example - Basics
Ganesh Samarthyam
 
PPTX
Docker Command Line, Using and Choosing containers
Will Hall
 
PDF
Introduction to Docker - Learning containerization XP conference 2016
XP Conference India
 
PPTX
Academy PRO: Docker. Part 2
Binary Studio
 
PPSX
Docker and containers - Presentation Slides by Priyadarshini Anand
PRIYADARSHINI ANAND
 
PPTX
DevOps: Docker Workshop
Joonas Hämäläinen
 
PPTX
Primi passi con Docker - ItalianCoders - 12-01-2021
Alessandro Mignogna
 
PDF
Master Docker - first meetup
Ayoub Benaissa
 
PDF
Docker
Brian Hogan
 
PDF
Docker navjot kaur
Navjot Kaur
 
PDF
Docker and the Container Revolution
Romain Dorgueil
 
PPTX
Docker Ecosystem on Azure
Patrick Chanezon
 
PDF
Docker, but what it is?
Julien Maitrehenry
 
PPTX
Docker Introductory workshop
Runcy Oommen
 
PPTX
Academy PRO: Docker. Lecture 2
Binary Studio
 
PDF
Dockers & kubernetes detailed - Beginners to Geek
wiTTyMinds1
 
PDF
Docker introduction
Julien Maitrehenry
 
PDF
Running the Oracle SOA Suite Environment in a Docker Container
Guido Schmutz
 
PPTX
Docker
Mutlu Okuducu
 
A Hands-on Introduction to Docker
CodeOps Technologies LLP
 
Docker by Example - Basics
Ganesh Samarthyam
 
Docker Command Line, Using and Choosing containers
Will Hall
 
Introduction to Docker - Learning containerization XP conference 2016
XP Conference India
 
Academy PRO: Docker. Part 2
Binary Studio
 
Docker and containers - Presentation Slides by Priyadarshini Anand
PRIYADARSHINI ANAND
 
DevOps: Docker Workshop
Joonas Hämäläinen
 
Primi passi con Docker - ItalianCoders - 12-01-2021
Alessandro Mignogna
 
Master Docker - first meetup
Ayoub Benaissa
 
Docker
Brian Hogan
 
Docker navjot kaur
Navjot Kaur
 
Docker and the Container Revolution
Romain Dorgueil
 
Docker Ecosystem on Azure
Patrick Chanezon
 
Docker, but what it is?
Julien Maitrehenry
 
Docker Introductory workshop
Runcy Oommen
 
Academy PRO: Docker. Lecture 2
Binary Studio
 
Dockers & kubernetes detailed - Beginners to Geek
wiTTyMinds1
 
Docker introduction
Julien Maitrehenry
 
Running the Oracle SOA Suite Environment in a Docker Container
Guido Schmutz
 
Ad

More from Dharmit Shah (13)

PDF
Introducing CentOS container pipeline
Dharmit Shah
 
PDF
Introduction to Kubernetes
Dharmit Shah
 
PDF
Introduction to Containers
Dharmit Shah
 
PDF
Git push to build, test and scan your containers
Dharmit Shah
 
PDF
Python in Industry
Dharmit Shah
 
PDF
Swarm mode
Dharmit Shah
 
PPTX
Ansible in CI
Dharmit Shah
 
PPTX
Introduction to ansible
Dharmit Shah
 
PDF
Kubernetes
Dharmit Shah
 
PDF
Atomic Developer Bundle
Dharmit Shah
 
PDF
Docker tips & tricks
Dharmit Shah
 
PPTX
Introducing docker
Dharmit Shah
 
PDF
Rest apis with DRF
Dharmit Shah
 
Introducing CentOS container pipeline
Dharmit Shah
 
Introduction to Kubernetes
Dharmit Shah
 
Introduction to Containers
Dharmit Shah
 
Git push to build, test and scan your containers
Dharmit Shah
 
Python in Industry
Dharmit Shah
 
Swarm mode
Dharmit Shah
 
Ansible in CI
Dharmit Shah
 
Introduction to ansible
Dharmit Shah
 
Kubernetes
Dharmit Shah
 
Atomic Developer Bundle
Dharmit Shah
 
Docker tips & tricks
Dharmit Shah
 
Introducing docker
Dharmit Shah
 
Rest apis with DRF
Dharmit Shah
 
Ad

Recently uploaded (20)

PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
Generative AI in Healthcare: Benefits, Use Cases & Challenges
Lily Clark
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PDF
Productivity Management Software | Workstatus
Lovely Baghel
 
PDF
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
PDF
UiPath on Tour London Community Booth Deck
UiPathCommunity
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
PDF
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Generative AI in Healthcare: Benefits, Use Cases & Challenges
Lily Clark
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
Productivity Management Software | Workstatus
Lovely Baghel
 
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
UiPath on Tour London Community Booth Deck
UiPathCommunity
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 

Docker hands-on

  • 3. Agenda Talk ➔ Understanding the Docker terminology ➔ What is a layer? ➔ What are Docker images? Hands-on ➔ Creating a container ➔ Creating a docker image ➔ Dockerfile ➔ Using nsenter
  • 4. What is a Layer? ➔ In traditional Linux, kernel mounts the root file system as read-only and later switches to read-write mode ➔ When Docker mounts the root, it starts read-only ➔ Later, instead of turning to read-write mode, it adds read-write file system over the read-only file system ➔ There could be multiple read-only file systems stacked on top of each other ➔ Each of this file system is called as layer
  • 5. What is a layer (contd..) ➔ Any time a process creates a file, this happens in top layer. ➔ If some file from lower layer needs to be updated, it first gets copied to top layer. ➔ Changes go into the copy ➔ Version of file on lower layer remains unchanged but cannot be seen by applications ➔ Union File System - union of read-write and all read-only layers
  • 6. What is a Layer? (contd.)
  • 7. What are Docker images? ➔ In Docker, a read-only layer is called in Image ➔ An image never changes ➔ Each image depends on one more image which forms the layer beneath it ➔ This lower image is sometimes referred to as Parent Image ➔ An image that has no parent image is called Base Image
  • 8. What are Docker images? (contd.)
  • 9. What are Docker images? (contd.)
  • 10. Creating a container $ sudo docker pull ubuntu:14.10 $ sudo docker run -ti ubuntu:14.10 /bin/bash $ ip a $ hostname $ uname -a
  • 11. Creating an image ➔ We will create a minimal image from the container we created in previous step $ sudo docker ps $ sudo docker ps -a $ man docker-commit $ sudo docker commit <container-id> -t <repository>/<tag> $ sudo docker tag <image> <tag>
  • 12. What is a Dockerfile? ➔ Automates building images ➔ A text document that contains commands to build an image ➔ Parsed by command docker buildto start image creation process ➔ Clone below repo: $ git clone https://github.com/dharmit/docker_ahmedabad_meetup_2/ ➔ Examine the Dockerfile
  • 13. What is a Dockerfile? (contd..) ➔ FROM python:3.4 ➔ WORKDIR /code ➔ ADD django_code /code ➔ RUN pip3 install -r requirements.txt ➔ CMD python3 manage.py runserver 0.0.0.0:8000
  • 14. Let’s build! ➔ $ sudo docker build -t docker_ahmedabad . ➔ $ sudo docker images ➔ $ sudo docker run -d -p 80:8000 docker_ahmedabad ➔ $ sudo docker ps ➔ In the browser, navigate to 127.0.0.1
  • 15. If it didn’t work for you
  • 16. nsenter ➔ Data backup ➔ Check logs ➔ Restart a service ➔ Edit configuration ➔ Debugging SSH
  • 17. nsenter (contd..) ➔ Provided by your distro’s util-linux package ➔ How to use it: $ PID=$(sudo docker inspect --format {{.State.Pid}} <container_name_or_ID>) $ nsenter --target $PID --mount --uts --ipc --net --pid /bin/bash ➔ Specify /bin/bash if you’re using a different shell
  • 18. Image and content credits ➔ http://docker.com ➔ http://redhat.com ➔ http://auberginesolutions.com