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

PPTX
Primi passi con Docker - ItalianCoders - 12-01-2021
PPTX
Academy PRO: Docker. Lecture 2
PDF
PDF
Docker puebla bday #4 celebration
PPTX
Docker for developers z java
PDF
[@NaukriEngineering] Docker 101
PPTX
Docker Starter Pack
PPTX
Docker workshop
Primi passi con Docker - ItalianCoders - 12-01-2021
Academy PRO: Docker. Lecture 2
Docker puebla bday #4 celebration
Docker for developers z java
[@NaukriEngineering] Docker 101
Docker Starter Pack
Docker workshop

What's hot (19)

PPTX
Docker and the Container Ecosystem
PDF
Vagrant and docker
PDF
Docker by Example - Basics
PDF
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
PPTX
[Codelab 2017] Docker 기초 및 활용 방안
PDF
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
PPT
Buildservicewithdockerin90mins
PDF
Introducing Docker
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
PPTX
Hands on introduction to docker security for docker newbies
PDF
Let's dockerize
PPTX
How to _docker
PDF
Docker by Example - Quiz
PDF
Docker for Deep Learning (Andrea Panizza)
PDF
Docker 101 - Intro to Docker
PPTX
Docker container a-brief_introduction_2016-01-30
PDF
docker installation and basics
PPTX
Docker introduction for the beginners
PDF
A Hands-on Introduction to Docker
Docker and the Container Ecosystem
Vagrant and docker
Docker by Example - Basics
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
[Codelab 2017] Docker 기초 및 활용 방안
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
Buildservicewithdockerin90mins
Introducing Docker
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Hands on introduction to docker security for docker newbies
Let's dockerize
How to _docker
Docker by Example - Quiz
Docker for Deep Learning (Andrea Panizza)
Docker 101 - Intro to Docker
Docker container a-brief_introduction_2016-01-30
docker installation and basics
Docker introduction for the beginners
A Hands-on Introduction to Docker
Ad

Similar to Docker @ Atlogys (20)

PDF
Docker.pdf
PDF
Introduction to Docker - Learning containerization XP conference 2016
PPTX
Docker, LinuX Container
PPTX
Docker Workshop
PDF
Docker introduction - Part 1
PDF
Getting Started with Docker
PDF
Docker in a JS Developer’s Life
PDF
Docker, but what it is?
PPTX
Powercoders · Docker · Fall 2021.pptx
PPTX
PPTX
PDF
Introduction of Docker and Docker Compose
PDF
Can you contain the future - Docker, Container Technologies, The Future, and You
PDF
Cloud Native Computing - Part III - Containers
PPTX
Containerization using docker and its applications
PPTX
Containerization using docker and its applications
PPT
14309525_docker_docker_docker_docker_introduction.ppt
PPSX
Docker Kubernetes Istio
PDF
docker.pdf
PPTX
Getting Started with Docker
Docker.pdf
Introduction to Docker - Learning containerization XP conference 2016
Docker, LinuX Container
Docker Workshop
Docker introduction - Part 1
Getting Started with Docker
Docker in a JS Developer’s Life
Docker, but what it is?
Powercoders · Docker · Fall 2021.pptx
Introduction of Docker and Docker Compose
Can you contain the future - Docker, Container Technologies, The Future, and You
Cloud Native Computing - Part III - Containers
Containerization using docker and its applications
Containerization using docker and its applications
14309525_docker_docker_docker_docker_introduction.ppt
Docker Kubernetes Istio
docker.pdf
Getting Started with Docker
Ad

More from Atlogys Technical Consulting (20)

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

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
The AUB Centre for AI in Media Proposal.docx
NewMind AI Weekly Chronicles - August'25 Week I
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A Presentation on Artificial Intelligence
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
MYSQL Presentation for SQL database connectivity
Chapter 3 Spatial Domain Image Processing.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Monthly Chronicles - July 2025
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...

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>