SlideShare a Scribd company logo
1 of 28
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
Agenda
What is DevOps?
DevOps Use Case
DevOps Phases
DevOps Hands-On
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
Topics for Today’s Session
www.edureka.co/devopsDevOps Certification Training
What is Docker?1
What is a Dockerfile?2
Dockerfile syntax3
Hands-on: Dockerizing Apache & Nginx4
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
What is Docker?
www.edureka.co/devopsDevOps Certification Training
The Old Way: Application on Host The New Way: Deploy Containers
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
How To Use Docker?
www.edureka.co/devopsDevOps Certification Training
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
How to build
Docker Images?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
How To Build Docker Images? – Using Predefined Images
www.edureka.co/devopsDevOps Certification Training
Pull Docker Images
Run Docker Images
to Create Docker
Containers
Docker
Container
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
What if I want to
create my own
image?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
How To Build Docker Images? – Using DockerFile
www.edureka.co/devopsDevOps Certification Training
DockerFile
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
Base Image
RUN
FROM
MAINTAINER
ADD
CMD
ENTRYPOINT
ENV
EXPOSE
USER
VOLUME
WORKDIR
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
How To Write A
DockerFile?
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Syntax
www.edureka.co/devopsDevOps Certification Training
Dockerfile syntax consists of two kind of main line blocks: comments and commands + arguments
# Line blocks used for commenting
command argument argument1...
Syntax
# Print “Welcome To Edureka!”
RUN echo “Welcome To Edureka!”
Example
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Let’s have a look at Different Set of Commands which DockerFile can
Contain Before working on a DockerFile Example
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – FROM
www.edureka.co/devopsDevOps Certification Training
FROM
FROM directive is probably the most crucial amongst all others for Dockerfiles. It defines the base image to
use to start the build process
# Usage: FROM [image name]
FROM ubuntu
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – RUN
www.edureka.co/devopsDevOps Certification Training
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
# Usage: RUN [command]
RUN apt-get install -y riak
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – CMD
www.edureka.co/devopsDevOps Certification Training
CMD
The command CMD, similar 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
# Usage 1: CMD application "argument", "argument", ..
CMD "echo" " Welcome To Edureka!"
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – ENTRYPOINT
www.edureka.co/devopsDevOps Certification Training
ENTRYPOINT
ENTRYPOINT argument sets the concrete default application that is used every time a container is created
using the image
# Usage: ENTRYPOINT application "argument", "argument", ..
# Remember: arguments are optional. They can be provided by CMD
# or during the creation of a container.
ENTRYPOINT echo
# Usage example with CMD:
# Arguments set with CMD can be overridden during *run* CMD "Hello docker!"
CMD “Welcome to edureka!”
ENTRYPOINT echo
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – ADD
www.edureka.co/devopsDevOps Certification Training
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
# Usage: ADD [source directory or URL] [destination directory]
ADD /my_app_folder /my_app_folder
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – ENV
www.edureka.co/devopsDevOps Certification Training
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
# Usage: ENV key value
ENV SERVER_WORKS 4
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – WORKDIR
www.edureka.co/devopsDevOps Certification Training
WORKDIR The WORKDIR directive is used to set where the command defined with CMD is to be executed
# Usage:
WORKDIR /path WORKDIR ~/
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – EXPOSE
www.edureka.co/devopsDevOps Certification Training
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)
# Usage: EXPOSE [port]
EXPOSE 8080
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – MAINTAINER
www.edureka.co/devopsDevOps Certification Training
MAINTAINER
This non-executing command declares the author, hence setting the author field of the images. It should
come nonetheless after FROM
# Usage: MAINTAINER [name]
MAINTAINER authors_name
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – USER
www.edureka.co/devopsDevOps Certification Training
USER
The USER directive is used to set the UID (or username) which is to run the container based on the image
being built
# Usage: USER [UID]
USER 751
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
DockerFile Commands – VOLUME
www.edureka.co/devopsDevOps Certification Training
VOLUME
The VOLUME command is used to enable access from your container to a directory on the host machine
(i.e. mounting it)
# Usage: VOLUME ["/dir_1", "/dir_2" ..]
VOLUME ["/my_files"]
Example:
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Creating an Image to Install Apache Web Server
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
FROM ubuntu:12.04
MAINTAINER edureka
RUN apt-get update && apt-get install -y apache2 && apt-get clean && rm -rf /var/lib/apt/lists/*
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
DockerFile For Installing Apache
www.edureka.co/devopsDevOps Certification Training
In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a
reverse proxy and load balancer for HTTP, TCP, and UDP servers.
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile For Installing Nginx
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
DockerFile Tutorial
www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING
FROM ubuntu:14.04
MAINTAINER edureka
RUN apt-get update
RUN apt-get install -y nginx
ADD index.html /usr/share/nginx/html/index.html
ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]
EXPOSE 80
DockerFile For Installing Nginx
www.edureka.co/devopsDevOps Certification Training
Apache2 Web Server. Apache is the most commonly used Web server on Linux systems. Web servers are used to serve Web
pages requested by client computers
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Training | Edureka

More Related Content

What's hot

Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Simplilearn
 

What's hot (20)

Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Docker Container Introduction
Docker Container IntroductionDocker Container Introduction
Docker Container Introduction
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker
DockerDocker
Docker
 
Docker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker SlidesDocker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker Slides
 
Dockerfile
Dockerfile Dockerfile
Dockerfile
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd productsDesigning a complete ci cd pipeline using argo events, workflow and cd products
Designing a complete ci cd pipeline using argo events, workflow and cd products
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
 
Docker introduction & benefits
Docker introduction & benefitsDocker introduction & benefits
Docker introduction & benefits
 
Kubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive OverviewKubernetes - A Comprehensive Overview
Kubernetes - A Comprehensive Overview
 
Docker and the Linux Kernel
Docker and the Linux KernelDocker and the Linux Kernel
Docker and the Linux Kernel
 
Kubernetes Architecture
 Kubernetes Architecture Kubernetes Architecture
Kubernetes Architecture
 

Similar to Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Training | Edureka

Similar to Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Training | Edureka (20)

Docker team training
Docker team trainingDocker team training
Docker team training
 
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | EdurekaDocker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
Docker Swarm For High Availability | Docker Tutorial | DevOps Tutorial | Edureka
 
Docker For Windows | Setting Up Docker On Windows | Edureka
Docker For Windows | Setting Up Docker On Windows | EdurekaDocker For Windows | Setting Up Docker On Windows | Edureka
Docker For Windows | Setting Up Docker On Windows | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 
Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
 
Docker @ Atlogys
Docker @ AtlogysDocker @ Atlogys
Docker @ Atlogys
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
 
dockerizing web application
dockerizing web applicationdockerizing web application
dockerizing web application
 
DevOps-Redefining your IT Strategy-28thJan15
DevOps-Redefining your IT Strategy-28thJan15DevOps-Redefining your IT Strategy-28thJan15
DevOps-Redefining your IT Strategy-28thJan15
 
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
 
Docker Networking | Container Network Model (CNM) | Docker Tutorial For Begin...
Docker Networking | Container Network Model (CNM) | Docker Tutorial For Begin...Docker Networking | Container Network Model (CNM) | Docker Tutorial For Begin...
Docker Networking | Container Network Model (CNM) | Docker Tutorial For Begin...
 
Docker Compose | Containerizing MEAN Stack Application | DevOps Tutorial | Ed...
Docker Compose | Containerizing MEAN Stack Application | DevOps Tutorial | Ed...Docker Compose | Containerizing MEAN Stack Application | DevOps Tutorial | Ed...
Docker Compose | Containerizing MEAN Stack Application | DevOps Tutorial | Ed...
 
Continuous Delivery with Docker and Jenkins pipeline
Continuous Delivery with Docker and Jenkins pipelineContinuous Delivery with Docker and Jenkins pipeline
Continuous Delivery with Docker and Jenkins pipeline
 
Docker how to
Docker how toDocker how to
Docker how to
 
Of Docker and Drupal
Of Docker and DrupalOf Docker and Drupal
Of Docker and Drupal
 
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
 
[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안[Codelab 2017] Docker 기초 및 활용 방안
[Codelab 2017] Docker 기초 및 활용 방안
 
Docker @ FOSS4G 2016, Bonn
Docker @ FOSS4G 2016, BonnDocker @ FOSS4G 2016, Bonn
Docker @ FOSS4G 2016, Bonn
 

More from Edureka!

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
ITIL® Tutorial for Beginners | ITIL® Foundation Training | Edureka
ITIL® Tutorial for Beginners | ITIL® Foundation Training | EdurekaITIL® Tutorial for Beginners | ITIL® Foundation Training | Edureka
ITIL® Tutorial for Beginners | ITIL® Foundation Training | Edureka
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Dockerfile Tutorial with Example | Creating your First Dockerfile | Docker Training | Edureka

  • 1. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING Agenda What is DevOps? DevOps Use Case DevOps Phases DevOps Hands-On
  • 2. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING Topics for Today’s Session www.edureka.co/devopsDevOps Certification Training What is Docker?1 What is a Dockerfile?2 Dockerfile syntax3 Hands-on: Dockerizing Apache & Nginx4
  • 3. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING What is Docker? www.edureka.co/devopsDevOps Certification Training The Old Way: Application on Host The New Way: Deploy Containers
  • 4. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING How To Use Docker? www.edureka.co/devopsDevOps Certification Training
  • 5. Copyright © 2017, edureka and/or its affiliates. All rights reserved. How to build Docker Images?
  • 6. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING How To Build Docker Images? – Using Predefined Images www.edureka.co/devopsDevOps Certification Training Pull Docker Images Run Docker Images to Create Docker Containers Docker Container
  • 7. Copyright © 2017, edureka and/or its affiliates. All rights reserved. What if I want to create my own image?
  • 8. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING How To Build Docker Images? – Using DockerFile www.edureka.co/devopsDevOps Certification Training DockerFile 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 Base Image RUN FROM MAINTAINER ADD CMD ENTRYPOINT ENV EXPOSE USER VOLUME WORKDIR
  • 9. Copyright © 2017, edureka and/or its affiliates. All rights reserved. How To Write A DockerFile?
  • 10. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Syntax www.edureka.co/devopsDevOps Certification Training Dockerfile syntax consists of two kind of main line blocks: comments and commands + arguments # Line blocks used for commenting command argument argument1... Syntax # Print “Welcome To Edureka!” RUN echo “Welcome To Edureka!” Example
  • 11. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Let’s have a look at Different Set of Commands which DockerFile can Contain Before working on a DockerFile Example
  • 12. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – FROM www.edureka.co/devopsDevOps Certification Training FROM FROM directive is probably the most crucial amongst all others for Dockerfiles. It defines the base image to use to start the build process # Usage: FROM [image name] FROM ubuntu Example:
  • 13. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – RUN www.edureka.co/devopsDevOps Certification Training 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 # Usage: RUN [command] RUN apt-get install -y riak Example:
  • 14. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – CMD www.edureka.co/devopsDevOps Certification Training CMD The command CMD, similar 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 # Usage 1: CMD application "argument", "argument", .. CMD "echo" " Welcome To Edureka!" Example:
  • 15. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – ENTRYPOINT www.edureka.co/devopsDevOps Certification Training ENTRYPOINT ENTRYPOINT argument sets the concrete default application that is used every time a container is created using the image # Usage: ENTRYPOINT application "argument", "argument", .. # Remember: arguments are optional. They can be provided by CMD # or during the creation of a container. ENTRYPOINT echo # Usage example with CMD: # Arguments set with CMD can be overridden during *run* CMD "Hello docker!" CMD “Welcome to edureka!” ENTRYPOINT echo Example:
  • 16. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – ADD www.edureka.co/devopsDevOps Certification Training 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 # Usage: ADD [source directory or URL] [destination directory] ADD /my_app_folder /my_app_folder Example:
  • 17. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – ENV www.edureka.co/devopsDevOps Certification Training 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 # Usage: ENV key value ENV SERVER_WORKS 4 Example:
  • 18. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – WORKDIR www.edureka.co/devopsDevOps Certification Training WORKDIR The WORKDIR directive is used to set where the command defined with CMD is to be executed # Usage: WORKDIR /path WORKDIR ~/ Example:
  • 19. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – EXPOSE www.edureka.co/devopsDevOps Certification Training 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) # Usage: EXPOSE [port] EXPOSE 8080 Example:
  • 20. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – MAINTAINER www.edureka.co/devopsDevOps Certification Training MAINTAINER This non-executing command declares the author, hence setting the author field of the images. It should come nonetheless after FROM # Usage: MAINTAINER [name] MAINTAINER authors_name Example:
  • 21. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – USER www.edureka.co/devopsDevOps Certification Training USER The USER directive is used to set the UID (or username) which is to run the container based on the image being built # Usage: USER [UID] USER 751 Example:
  • 22. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING DockerFile Commands – VOLUME www.edureka.co/devopsDevOps Certification Training VOLUME The VOLUME command is used to enable access from your container to a directory on the host machine (i.e. mounting it) # Usage: VOLUME ["/dir_1", "/dir_2" ..] VOLUME ["/my_files"] Example:
  • 23. Copyright © 2017, edureka and/or its affiliates. All rights reserved. Creating an Image to Install Apache Web Server
  • 24. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING FROM ubuntu:12.04 MAINTAINER edureka RUN apt-get update && apt-get install -y apache2 && apt-get clean && rm -rf /var/lib/apt/lists/* ENV APACHE_RUN_USER www-data ENV APACHE_RUN_GROUP www-data ENV APACHE_LOG_DIR /var/log/apache2 EXPOSE 80 CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"] DockerFile For Installing Apache www.edureka.co/devopsDevOps Certification Training In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers.
  • 25. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile For Installing Nginx
  • 26. Copyright © 2017, edureka and/or its affiliates. All rights reserved. DockerFile Tutorial www.edureka.co/devopsDEVOPS CERTIFICATION TRAINING FROM ubuntu:14.04 MAINTAINER edureka RUN apt-get update RUN apt-get install -y nginx ADD index.html /usr/share/nginx/html/index.html ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"] EXPOSE 80 DockerFile For Installing Nginx www.edureka.co/devopsDevOps Certification Training Apache2 Web Server. Apache is the most commonly used Web server on Linux systems. Web servers are used to serve Web pages requested by client computers
  • 27. Copyright © 2017, edureka and/or its affiliates. All rights reserved.