SlideShare a Scribd company logo
Introduction To Docker
Build and Ship Application with Docker
By -
Ram Awadh Chauhan
Senior Software Engineer
Atlogys Technical Consulting
Today’s Agenda
1: About docker
2: Difference between Virtualization and Containerization.
3: Why Docker?
4: Docker Architecture, basic terms and commands
5: Dockerizing a project with docker (Django App, live Demo, Volume mount Etc)
● Environment variables (ADD, COPY, ENV, EXPOSE, FROM, WORKDIR,
ENTRYPOINT, CMD)
https://docs.docker.com/engine/reference/builder/#environment-replacement
● Differences b/w CMD and ENTRYPOINT with example
● Create a DockerFile
● Build an Image
● Run the Application
● Volume mount from Host machine to container
● Start, Stop , Delete, Remove commands
7: Who are using it?
8: Q & A sessions.
About Docker
1: Docker is a computer program that performs operating-system-level virtualization also
known as containerization.
2: Docker firstly started by “Solomon Hykes” in france as internal Project inside dotCloud.
3: It was first released in March 2013 as open source Project.
4: Docker is written in GO language.
5: It was primarily supported only Linux operating system where it used the resource
isolation feature of linux kernel.
6: Docker is used to run software packages called "containers".
7: In a typical example use case, one container runs a web server and web application,
while a second container runs a database server that is used by the web application.
8: Containers are isolated from each others and use their own set of tools and libraries.
9: Containers can communicate through well-defined channels.
10: All containers use the same kernel and are therefore more lightweight than virtual
machines.
Difference between Virtualization and
Containerization
Virtualization Containerization
Why Docker?
1: Light weight: Docker container are light weight, only include binaries of the
application.
2: Efficient: Minimizes deployment cost and it is very efficient.
3: Fixes Environment based Issue: Removes the environment based issues, like
code is working on some environment and not working on some other environments.
4: Very Flexible: Can be ported on any environment by pulling. Copying from one
environment to another environment even can be run inside Amazon EC2 and
Google Compute Engine instance also on VMS.
5: Isolation: Docker makes sure each container has its own resources that are
isolated from other containers.
Docker Architecture, Basic Terms and
Commands
Docker Architecture, Basic Terms and
Commands …. Continued
Docker Client: This (docker Client) is the primary way by which docker user interact with
docker i.e. docker run
Docker Registries: Docker registry stores docker images. Docker hub and Docker
Cloud are public registries that anyone can use, and Docker is configured to look for
images on Docker hub by default. Docker pull <image-name> can be used to pull the
images. And Docker push <mage=name > to publish docker images on docker hub.
Docker Images: An Image is a read-only template with instructions for creating a Docker
container.
Docker Container: A Container is a runnable instance of an Image. These can be
created, started, stopped or deleted using docker Api or CLI commands.
Docker Architecture, Basic Terms and
Commands …. Continued
List of important commands which can be used by Docker CLI:
1. docker pull: Pull a image from registry
2. Docker build : build and image from dockerfile
3. Docker run: Runs a container
4. docker start: Start one or more stoped container
5. docker stop: Stop one or more running containers
6. docker ps: List containers which are running
7. docker ps -a: List all containers
8. docker kill: Kill one or more running containers
9. docker logs: Fetch the logs of a container
10. docker login: Login into Docker registry like Docker hub
11. docker logout: Logout from the Docker registry
Docker Architecture, Basic Terms and
Commands …. Continued
12: docker rename: Rename a container
13: docker restart: Restart one or more containers
14: docker rm : Remove one or more containers
15: docker rmi: Remove one or more images
16: docker stats: Display a live stream of container(s) resource usage statistics
17: docker tag: Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
18: docker top: Display the running processes of a container
19: docker version: Show the docker version
16: docker port: List port mappings or a specific mapping for the container
15: Docker history: Shows the history of an image
16: docker push: Push a image into the registry
Docker Architecture, Basic Terms and
Commands …. Continued
17: Docker export: Export a container’s filesystem as a tar archive
18: Docker image <subcommand> : Manage images with following commands
● docker image import: Import the contents from a tarball to create a filesystem
image
● docker image inspect: Display detailed information on one or more images
● docker image load: Load an image from a tar archive or STDIN
● docker image ls: List images
● docker image prune: Remove unused images
● docker image pull: Pull an image or a repository from a registry
● docker image push: Push an image or a repository to a registry
● docker image rm: Remove one or more images
About Dockerfile and commands
The Dockerfile is a building block of instruction to build the image, also Dockerfile is a
script, composed of various commands (instructions) and arguments listed
successively to automatically perform actions on a base image in order to create (or
form) a new one. They are used for organizing things and greatly help with
deployments by simplifying the process start-to-finish.
Commands:
ADD, CMD, ENTRYPOINT, ENV, EXPOSE, FROM, MAINTAINER, RUN, USER,
VOLUME, WORKDIR
About Dockerfile and commands
ADD:
The ADD command gets two arguments: a source and a destination. It
basically copies the files from the source on the host into the container's own
filesystem at the set destination. If, however, the source is a URL (e.g.
http://github.com/user/file/), then the contents of the URL are downloaded and placed
at the destination.
Example:
docker ADD [source directory or URL] [destination directory]
About Dockerfile and commands
CMD:
The command CMD, similarly to RUN, can be used for executing a specific
command. However, unlike RUN it is not executed during build, but when a
container is instantiated using the image being built. Therefore, it should be
considered as an initial, default command that gets executed (i.e. run) with the
creation of containers based on the image.
Example:
CMD "echo" "Hello docker!"
About Dockerfile and commands
ENTRYPOINT:
ENTRYPOINT argument sets the concrete default application that is used
every time a container is created using the image. For example, if you have installed
a specific application inside an image and you will use this image to only run that
application, you can state it with ENTRYPOINT and whenever a container is created
from that image, your application will be the target..
Example:
ENTRYPOINT application "argument", "argument", ..
CMD "Hello docker!"
ENTRYPOINT "echo"
About Dockerfile and commands
ENV:
The ENV command is used to set the environment variables (one or more).
These variables consist of “key value” pairs which can be accessed within the
container by scripts and applications alike. This functionality of Docker offers an
enormous amount of flexibility for running programs.
Example:
ENV SERVER_WORKS 4
About Dockerfile and commands
EXPOSE:
The EXPOSE command is used to associate a specified port to enable
networking between the running process inside the container and the outside world
(i.e. the host).
Example:
EXPOSE 8080
About Dockerfile and commands
FROM:
It defines the base image to use to start the build process. It can be any image,
including the ones you have created previously. If a FROM image is not found on the
host, Docker will try to find it (and download) from the Docker Hub or other container
repository. It needs to be the first command declared inside a Dockerfile.
Example:
FROM ubuntu:16.04
About Dockerfile and commands
MAINTAINER:
One of the commands that can be set anywhere in the file - although it would
be better if it was declared on top - is MAINTAINER. This non-executing command
declares the author, hence setting the author field of the images. It should come
nonetheless after FROM.
Example:
MAINTAINER authors_name
About Dockerfile and commands
RUN:
The RUN command is the central executing directive for Dockerfiles. It takes a
command as its argument and runs it to form the image. Unlike CMD, it actually is
used to build the image (forming another layer on top of the previous one which is
committed).
Example:
RUN pip install -r requirements.txt
About Dockerfile and commands
USER:
The USER directive is used to set the UID (or username) which is to run the
container based on the image being built.
Example: USER 751
VOLUME:
The VOLUME command is used to enable access from your container to a
directory on the host machine (i.e. mounting it).
Example: VOLUME ["/my_files"]
About Dockerfile and commands
WORKDIR:
The WORKDIR directive is used to set where the command defined with CMD
is to be executed.
Example: WORKDIR ~/
Difference b/w CMD and ENTRYPOINT
1: You need at least one (ENTRYPOINT or CMD) defined (in order to run)
2: if just one is defined at runtime, CMD and ENTRYPOINT have the same effect
3: For both CMD and ENTRYPOINT, there are "shell" and "exec" versions
4: CMD arguments append to end of ENTRYPOINT sometimes
a: If you use "shell" format for ENTRYPOINT, CMD is ignored.
b: If you use "exec" format for ENTRYPOINT, CMD arguments are appended
after.
5: ENTRYPOINT and CMD can be overridden via command line flags.
Sample Dockerfile
FROM ubuntu:16.04
RUN apt-get update && apt-get -y upgrade
RUN apt install -y libffi-dev python-docutils pkg-config python3-dev python3-pip
RUN rm -r /usr/bin/python
RUN ln -s /usr/bin/python3.5 /usr/bin/python
RUN apt-get install -y python3-dev pkg-config
RUN mkdir /home/docker-demo
#RUN mkdir /var/code
ADD . /home/docker-demo/
WORKDIR /home/docker-demo
RUN pip3 install -r requirements.txt
#RUN ln -s /home/docker-demo /var/code
EXPOSE 8000
ENTRYPOINT ["python", "manage.py"]
CMD ["runserver", "0.0.0.0:8000"]
Build docker file and run docker file
Commands:
docker build --rm -t docker-test .
Run the images:
docker run -d -v
/home/ram/Work/PeopleTicker/docker-demo/first_app/templates/first_app:/home/dec
ker-demo/first_app/templates/first_app -p 8000:8000 --name=demo docker-test
Push an image to dockerhub
Prerequisites:
You need to create an account and a repository in hub.docker.com
Then need to follow below steps.
-> docker login --username=<user-name>
-> docker tag <image-name> <registry-name>
-> docker push <repository-name>
Thank You !!!!

More Related Content

What's hot (19)

PPTX
Docker and the Container Ecosystem
psconnolly
 
PDF
Vagrant and docker
DuckDuckGo
 
PDF
Docker by Example - Basics
CodeOps Technologies LLP
 
PDF
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Edureka!
 
PPTX
[Codelab 2017] Docker 기초 및 활용 방안
양재동 코드랩
 
PDF
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Edureka!
 
PPT
Buildservicewithdockerin90mins
Yong Cha
 
PDF
Introducing Docker
Francesco Pantano
 
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
PPTX
Hands on introduction to docker security for docker newbies
Yigal Elefant
 
PDF
Let's dockerize
Ahmed Sorour
 
PPTX
How to _docker
Abdur Rab Marjan
 
PDF
Docker by Example - Quiz
CodeOps Technologies LLP
 
PDF
Docker for Deep Learning (Andrea Panizza)
MeetupDataScienceRoma
 
PDF
Docker 101 - Intro to Docker
Adrian Otto
 
PPTX
Docker container a-brief_introduction_2016-01-30
Khelender Sasan
 
PDF
docker installation and basics
Walid Ashraf
 
PPTX
Docker introduction for the beginners
Juneyoung Oh
 
PDF
A Hands-on Introduction to Docker
CodeOps Technologies LLP
 
Docker and the Container Ecosystem
psconnolly
 
Vagrant and docker
DuckDuckGo
 
Docker by Example - Basics
CodeOps Technologies LLP
 
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Edureka!
 
[Codelab 2017] Docker 기초 및 활용 방안
양재동 코드랩
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Edureka!
 
Buildservicewithdockerin90mins
Yong Cha
 
Introducing Docker
Francesco Pantano
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
Hands on introduction to docker security for docker newbies
Yigal Elefant
 
Let's dockerize
Ahmed Sorour
 
How to _docker
Abdur Rab Marjan
 
Docker by Example - Quiz
CodeOps Technologies LLP
 
Docker for Deep Learning (Andrea Panizza)
MeetupDataScienceRoma
 
Docker 101 - Intro to Docker
Adrian Otto
 
Docker container a-brief_introduction_2016-01-30
Khelender Sasan
 
docker installation and basics
Walid Ashraf
 
Docker introduction for the beginners
Juneyoung Oh
 
A Hands-on Introduction to Docker
CodeOps Technologies LLP
 

Similar to Docker @ Atlogys (20)

PDF
Docker.pdf
UsamaMushtaq24
 
PDF
Introduction to Docker - Learning containerization XP conference 2016
XP Conference India
 
PPTX
Docker, LinuX Container
Araf Karsh Hamid
 
PPTX
Docker Workshop
Ahmad Rafiee
 
PDF
Docker introduction - Part 1
Alessandro Mignogna
 
PDF
Getting Started with Docker
Anup Segu
 
PDF
Docker in a JS Developer’s Life
GlobalLogic Ukraine
 
PDF
Docker, but what it is?
Julien Maitrehenry
 
PPTX
Powercoders · Docker · Fall 2021.pptx
IgnacioTamayo2
 
PPTX
Docker
Hussien Elhannan
 
PPTX
Docker
Dmitry Bolgarov
 
PDF
Introduction of Docker and Docker Compose
Dr. Ketan Parmar
 
PDF
Can you contain the future - Docker, Container Technologies, The Future, and You
ColdFusionConference
 
PDF
Cloud Native Computing - Part III - Containers
Linjith Kunnon
 
PPTX
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPTX
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
PPT
14309525_docker_docker_docker_docker_introduction.ppt
aravym456
 
PPSX
Docker Kubernetes Istio
Araf Karsh Hamid
 
PDF
docker.pdf
vivekpatnaik8
 
PPTX
Getting Started with Docker
Geeta Vinnakota
 
Docker.pdf
UsamaMushtaq24
 
Introduction to Docker - Learning containerization XP conference 2016
XP Conference India
 
Docker, LinuX Container
Araf Karsh Hamid
 
Docker Workshop
Ahmad Rafiee
 
Docker introduction - Part 1
Alessandro Mignogna
 
Getting Started with Docker
Anup Segu
 
Docker in a JS Developer’s Life
GlobalLogic Ukraine
 
Docker, but what it is?
Julien Maitrehenry
 
Powercoders · Docker · Fall 2021.pptx
IgnacioTamayo2
 
Introduction of Docker and Docker Compose
Dr. Ketan Parmar
 
Can you contain the future - Docker, Container Technologies, The Future, and You
ColdFusionConference
 
Cloud Native Computing - Part III - Containers
Linjith Kunnon
 
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
Containerization using docker and its applications
Puneet Kumar Bhatia (MBA, ITIL V3 Certified)
 
14309525_docker_docker_docker_docker_introduction.ppt
aravym456
 
Docker Kubernetes Istio
Araf Karsh Hamid
 
docker.pdf
vivekpatnaik8
 
Getting Started with Docker
Geeta Vinnakota
 
Ad

More from Atlogys Technical Consulting (20)

PPTX
Latest UI guidelines for Web Apps
Atlogys Technical Consulting
 
PDF
Discipline at Atlogys
Atlogys Technical Consulting
 
PDF
Reprogram your mind for Positive Thinking
Atlogys Technical Consulting
 
PDF
Tests for Scalable, Fast, Secure Apps
Atlogys Technical Consulting
 
PDF
Atomic Design with PatternLabs
Atlogys Technical Consulting
 
PDF
Git and Version Control at Atlogys
Atlogys Technical Consulting
 
PDF
Guidelines HTML5 & CSS3 - Atlogys (2018)
Atlogys Technical Consulting
 
PDF
Rabbit MQ - Tech Talk at Atlogys
Atlogys Technical Consulting
 
PDF
BDD and Test Automation Tech Talk - Atlogys Academy Series
Atlogys Technical Consulting
 
PDF
QA Best Practices at Atlogys - Tech Talk (Atlogys Academy)
Atlogys Technical Consulting
 
PDF
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
Atlogys Technical Consulting
 
PDF
How Solr Search Works
Atlogys Technical Consulting
 
PDF
Wordpress Tech Talk
Atlogys Technical Consulting
 
PDF
Tech Talk on ReactJS
Atlogys Technical Consulting
 
PPTX
Atlogys Academy - Tech Talk on Mongo DB
Atlogys Technical Consulting
 
PDF
Atlogys Tech Talk - Web 2.0 Design Guidelines
Atlogys Technical Consulting
 
PDF
Firebase Tech Talk By Atlogys
Atlogys Technical Consulting
 
PPTX
Atlogys - Don’t Just Sell Technology, Sell The Experience!
Atlogys Technical Consulting
 
PPT
Smart CTO Service
Atlogys Technical Consulting
 
PPT
Atlogys Technical Consulting
Atlogys Technical Consulting
 
Latest UI guidelines for Web Apps
Atlogys Technical Consulting
 
Discipline at Atlogys
Atlogys Technical Consulting
 
Reprogram your mind for Positive Thinking
Atlogys Technical Consulting
 
Tests for Scalable, Fast, Secure Apps
Atlogys Technical Consulting
 
Atomic Design with PatternLabs
Atlogys Technical Consulting
 
Git and Version Control at Atlogys
Atlogys Technical Consulting
 
Guidelines HTML5 & CSS3 - Atlogys (2018)
Atlogys Technical Consulting
 
Rabbit MQ - Tech Talk at Atlogys
Atlogys Technical Consulting
 
BDD and Test Automation Tech Talk - Atlogys Academy Series
Atlogys Technical Consulting
 
QA Best Practices at Atlogys - Tech Talk (Atlogys Academy)
Atlogys Technical Consulting
 
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
Atlogys Technical Consulting
 
How Solr Search Works
Atlogys Technical Consulting
 
Wordpress Tech Talk
Atlogys Technical Consulting
 
Tech Talk on ReactJS
Atlogys Technical Consulting
 
Atlogys Academy - Tech Talk on Mongo DB
Atlogys Technical Consulting
 
Atlogys Tech Talk - Web 2.0 Design Guidelines
Atlogys Technical Consulting
 
Firebase Tech Talk By Atlogys
Atlogys Technical Consulting
 
Atlogys - Don’t Just Sell Technology, Sell The Experience!
Atlogys Technical Consulting
 
Smart CTO Service
Atlogys Technical Consulting
 
Atlogys Technical Consulting
Atlogys Technical Consulting
 
Ad

Recently uploaded (20)

PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PPTX
Using Google Data Studio (Looker Studio) to Create Effective and Easy Data Re...
Orage Technologies
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PDF
SalesForce Managed Services Benefits (1).pdf
TechForce Services
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
Using Google Data Studio (Looker Studio) to Create Effective and Easy Data Re...
Orage Technologies
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
SalesForce Managed Services Benefits (1).pdf
TechForce Services
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 

Docker @ Atlogys

  • 1. Introduction To Docker Build and Ship Application with Docker By - Ram Awadh Chauhan Senior Software Engineer Atlogys Technical Consulting
  • 2. Today’s Agenda 1: About docker 2: Difference between Virtualization and Containerization. 3: Why Docker? 4: Docker Architecture, basic terms and commands 5: Dockerizing a project with docker (Django App, live Demo, Volume mount Etc) ● Environment variables (ADD, COPY, ENV, EXPOSE, FROM, WORKDIR, ENTRYPOINT, CMD) https://docs.docker.com/engine/reference/builder/#environment-replacement ● Differences b/w CMD and ENTRYPOINT with example ● Create a DockerFile ● Build an Image ● Run the Application ● Volume mount from Host machine to container ● Start, Stop , Delete, Remove commands 7: Who are using it? 8: Q & A sessions.
  • 3. About Docker 1: Docker is a computer program that performs operating-system-level virtualization also known as containerization. 2: Docker firstly started by “Solomon Hykes” in france as internal Project inside dotCloud. 3: It was first released in March 2013 as open source Project. 4: Docker is written in GO language. 5: It was primarily supported only Linux operating system where it used the resource isolation feature of linux kernel. 6: Docker is used to run software packages called "containers". 7: In a typical example use case, one container runs a web server and web application, while a second container runs a database server that is used by the web application. 8: Containers are isolated from each others and use their own set of tools and libraries. 9: Containers can communicate through well-defined channels. 10: All containers use the same kernel and are therefore more lightweight than virtual machines.
  • 4. Difference between Virtualization and Containerization Virtualization Containerization
  • 5. Why Docker? 1: Light weight: Docker container are light weight, only include binaries of the application. 2: Efficient: Minimizes deployment cost and it is very efficient. 3: Fixes Environment based Issue: Removes the environment based issues, like code is working on some environment and not working on some other environments. 4: Very Flexible: Can be ported on any environment by pulling. Copying from one environment to another environment even can be run inside Amazon EC2 and Google Compute Engine instance also on VMS. 5: Isolation: Docker makes sure each container has its own resources that are isolated from other containers.
  • 6. Docker Architecture, Basic Terms and Commands
  • 7. Docker Architecture, Basic Terms and Commands …. Continued Docker Client: This (docker Client) is the primary way by which docker user interact with docker i.e. docker run Docker Registries: Docker registry stores docker images. Docker hub and Docker Cloud are public registries that anyone can use, and Docker is configured to look for images on Docker hub by default. Docker pull <image-name> can be used to pull the images. And Docker push <mage=name > to publish docker images on docker hub. Docker Images: An Image is a read-only template with instructions for creating a Docker container. Docker Container: A Container is a runnable instance of an Image. These can be created, started, stopped or deleted using docker Api or CLI commands.
  • 8. Docker Architecture, Basic Terms and Commands …. Continued List of important commands which can be used by Docker CLI: 1. docker pull: Pull a image from registry 2. Docker build : build and image from dockerfile 3. Docker run: Runs a container 4. docker start: Start one or more stoped container 5. docker stop: Stop one or more running containers 6. docker ps: List containers which are running 7. docker ps -a: List all containers 8. docker kill: Kill one or more running containers 9. docker logs: Fetch the logs of a container 10. docker login: Login into Docker registry like Docker hub 11. docker logout: Logout from the Docker registry
  • 9. Docker Architecture, Basic Terms and Commands …. Continued 12: docker rename: Rename a container 13: docker restart: Restart one or more containers 14: docker rm : Remove one or more containers 15: docker rmi: Remove one or more images 16: docker stats: Display a live stream of container(s) resource usage statistics 17: docker tag: Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE 18: docker top: Display the running processes of a container 19: docker version: Show the docker version 16: docker port: List port mappings or a specific mapping for the container 15: Docker history: Shows the history of an image 16: docker push: Push a image into the registry
  • 10. Docker Architecture, Basic Terms and Commands …. Continued 17: Docker export: Export a container’s filesystem as a tar archive 18: Docker image <subcommand> : Manage images with following commands ● docker image import: Import the contents from a tarball to create a filesystem image ● docker image inspect: Display detailed information on one or more images ● docker image load: Load an image from a tar archive or STDIN ● docker image ls: List images ● docker image prune: Remove unused images ● docker image pull: Pull an image or a repository from a registry ● docker image push: Push an image or a repository to a registry ● docker image rm: Remove one or more images
  • 11. About Dockerfile and commands The Dockerfile is a building block of instruction to build the image, also Dockerfile is a script, composed of various commands (instructions) and arguments listed successively to automatically perform actions on a base image in order to create (or form) a new one. They are used for organizing things and greatly help with deployments by simplifying the process start-to-finish. Commands: ADD, CMD, ENTRYPOINT, ENV, EXPOSE, FROM, MAINTAINER, RUN, USER, VOLUME, WORKDIR
  • 12. About Dockerfile and commands ADD: The ADD command gets two arguments: a source and a destination. It basically copies the files from the source on the host into the container's own filesystem at the set destination. If, however, the source is a URL (e.g. http://github.com/user/file/), then the contents of the URL are downloaded and placed at the destination. Example: docker ADD [source directory or URL] [destination directory]
  • 13. About Dockerfile and commands CMD: The command CMD, similarly to RUN, can be used for executing a specific command. However, unlike RUN it is not executed during build, but when a container is instantiated using the image being built. Therefore, it should be considered as an initial, default command that gets executed (i.e. run) with the creation of containers based on the image. Example: CMD "echo" "Hello docker!"
  • 14. About Dockerfile and commands ENTRYPOINT: ENTRYPOINT argument sets the concrete default application that is used every time a container is created using the image. For example, if you have installed a specific application inside an image and you will use this image to only run that application, you can state it with ENTRYPOINT and whenever a container is created from that image, your application will be the target.. Example: ENTRYPOINT application "argument", "argument", .. CMD "Hello docker!" ENTRYPOINT "echo"
  • 15. About Dockerfile and commands ENV: The ENV command is used to set the environment variables (one or more). These variables consist of “key value” pairs which can be accessed within the container by scripts and applications alike. This functionality of Docker offers an enormous amount of flexibility for running programs. Example: ENV SERVER_WORKS 4
  • 16. About Dockerfile and commands EXPOSE: The EXPOSE command is used to associate a specified port to enable networking between the running process inside the container and the outside world (i.e. the host). Example: EXPOSE 8080
  • 17. About Dockerfile and commands FROM: It defines the base image to use to start the build process. It can be any image, including the ones you have created previously. If a FROM image is not found on the host, Docker will try to find it (and download) from the Docker Hub or other container repository. It needs to be the first command declared inside a Dockerfile. Example: FROM ubuntu:16.04
  • 18. About Dockerfile and commands MAINTAINER: One of the commands that can be set anywhere in the file - although it would be better if it was declared on top - is MAINTAINER. This non-executing command declares the author, hence setting the author field of the images. It should come nonetheless after FROM. Example: MAINTAINER authors_name
  • 19. About Dockerfile and commands RUN: The RUN command is the central executing directive for Dockerfiles. It takes a command as its argument and runs it to form the image. Unlike CMD, it actually is used to build the image (forming another layer on top of the previous one which is committed). Example: RUN pip install -r requirements.txt
  • 20. About Dockerfile and commands USER: The USER directive is used to set the UID (or username) which is to run the container based on the image being built. Example: USER 751 VOLUME: The VOLUME command is used to enable access from your container to a directory on the host machine (i.e. mounting it). Example: VOLUME ["/my_files"]
  • 21. About Dockerfile and commands WORKDIR: The WORKDIR directive is used to set where the command defined with CMD is to be executed. Example: WORKDIR ~/
  • 22. Difference b/w CMD and ENTRYPOINT 1: You need at least one (ENTRYPOINT or CMD) defined (in order to run) 2: if just one is defined at runtime, CMD and ENTRYPOINT have the same effect 3: For both CMD and ENTRYPOINT, there are "shell" and "exec" versions 4: CMD arguments append to end of ENTRYPOINT sometimes a: If you use "shell" format for ENTRYPOINT, CMD is ignored. b: If you use "exec" format for ENTRYPOINT, CMD arguments are appended after. 5: ENTRYPOINT and CMD can be overridden via command line flags.
  • 23. Sample Dockerfile FROM ubuntu:16.04 RUN apt-get update && apt-get -y upgrade RUN apt install -y libffi-dev python-docutils pkg-config python3-dev python3-pip RUN rm -r /usr/bin/python RUN ln -s /usr/bin/python3.5 /usr/bin/python RUN apt-get install -y python3-dev pkg-config RUN mkdir /home/docker-demo #RUN mkdir /var/code ADD . /home/docker-demo/ WORKDIR /home/docker-demo RUN pip3 install -r requirements.txt #RUN ln -s /home/docker-demo /var/code EXPOSE 8000 ENTRYPOINT ["python", "manage.py"] CMD ["runserver", "0.0.0.0:8000"]
  • 24. Build docker file and run docker file Commands: docker build --rm -t docker-test . Run the images: docker run -d -v /home/ram/Work/PeopleTicker/docker-demo/first_app/templates/first_app:/home/dec ker-demo/first_app/templates/first_app -p 8000:8000 --name=demo docker-test
  • 25. Push an image to dockerhub Prerequisites: You need to create an account and a repository in hub.docker.com Then need to follow below steps. -> docker login --username=<user-name> -> docker tag <image-name> <registry-name> -> docker push <repository-name>