SlideShare a Scribd company logo
DOCKER ADVANCE 1
Day-2
TOPICS
• Docker Installation
• Docker Network
• Docker Volume
• Dockerfile
DOCKER INSTALLATION
• Docker comes in 2 editions Docker CE (Community edition) and Docker EE
(Enterprise Edition).
Stable – gives you latest releases for general availability.
Test – gives pre-releases that are ready for testing before general availability.
Nightly – gives you the latest builds of work in progress for the next major
release.
INSTALL DOCKER ENGINE ON CENTOS
• SET UP THE REPOSITORY
$ sudo yum install -y yum-utils
$ sudo yum-config-manager 
--add-repo 
https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum-config-manager --enable docker-ce-nightly
$ sudo yum-config-manager --enable docker-ce-test
$ sudo yum-config-manager --disable docker-ce-nightly
Install the latest version of Docker Engine
$ sudo yum install docker-ce docker-ce-cli containerd.io
$ sudo systemctl start docker
$ sudo docker run hello-world
CONT..
• Uninstall old versions
$ sudo yum remove docker 
docker-client 
docker-client-latest 
docker-common 
docker-latest 
docker-latest-logrotate 
docker-logrotate 
docker-engine
DOCKER NETWORKING
• One of the reasons Docker containers and services are so powerful is
that you can connect them together, or connect them to non-Docker
workloads.
• Network drivers
1. Bridge
2. Host
3. Overlay
4. Macvlan
BRIDGE
• The default network driver.
• If you don’t specify a driver, this is the type of network you are
creating.
• Bridge networks are usually used when your applications run in
standalone containers that need to communicate.
BRIDGE
CONCEPT
TYPES OF BRIDGE
• User-defined bridges
• Default bridge
USER-DEFINED BRIDGES
• User-defined bridges provide automatic DNS resolution
between containers:
Containers on the default bridge network can only access
each other by IP addresses, unless you use the --link option,
which is considered legacy. On a user-defined bridge network,
containers can resolve each other by name or alias.
• User-defined bridges provide better isolation:
All containers without a --network specified, are attached
to the default bridge network. This can be a risk, as unrelated
stacks/services/containers are then able to communicate.
CONT…
• Containers can be attached and detached from user-defined
networks on the fly:
During a container’s lifetime, you can connect or disconnect it
from user-defined networks on the fly. To remove a container from the
default bridge network, you need to stop the container and recreate it
with different network options.
• Each user-defined network creates a configurable bridge:
If your containers use the default bridge network, you can
configure it, but all the containers use the same settings, such as MTU
and iptables rules. In addition, configuring the default bridge network
happens outside of Docker itself, and requires a restart of Docker.
COMMAND
• $ docker network create my-net  new network bridge creation
• $ ifconfig  To verify the bridge configuration
• docker create --name my-nginx 
--network my-net 
--publish 8080:80 
nginx:latest
docker network connect my-net my-nginx
docker network disconnect my-net my-nginx
docker network rm my-net  Remove the newly created bridge
DOCKER VOLUMES
• Volumes are the preferred mechanism for persisting data generated by and
used by Docker containers.
• Volumes are easier to back up or migrate than bind mounts.
• You can manage volumes using Docker CLI commands or the Docker API.
• Volumes work on both Linux and Windows containers.
• Volumes can be more safely shared among multiple containers.
• Volume drivers let you store volumes on remote hosts or cloud providers, to
encrypt the contents of volumes, or to add other functionality.
• New volumes can have their content pre-populated by a container.
• Command Flags –v or --mount
CREATE AND MANAGE VOLUMES
• Create a volume:
docker volume create my-vol
• List volumes:
docker volume ls
• Inspect a volume:
docker volume inspect my-vol
• Remove a volume:
docker volume rm my-vol
START A CONTAINER WITH A VOLUME
• With flag --mount
docker run -d 
--name devtest 
--mount source=myvol2,target=/app 
nginx:latest
• With Flag –v
docker run -d 
--name devtest 
-v myvol2:/app 
nginx:latest
CONT…
• Run the CMD,
docker inspect devtest  Check the parameters
• Removing CMD,
docker container stop devtest
docker container rm devtest
docker volume rm myvol2
START A SERVICE WITH VOLUMES
docker service create -d 
--replicas=4 
--name devtest-service 
--mount source=myvol2,target=/app 
nginx:latest
$ docker service ps devtest-service
docker inspect nginxtest
docker service rm devtest-service
READ-ONLY VOLUME
docker run -d 
--name=nginxtest 
-v nginx-vol:/usr/share/nginx/html:ro 
nginx:latest
docker run -d 
--name=nginxtest 
--mount source=nginx-
vol,destination=/usr/share/nginx/html,readonly 
nginx:latest
docker inspect nginxtest
DOCKERFILE
• A Dockerfile is a script/text configuration file that contains
collections of commands and instructions that will be
automatically executed in sequence in the docker environment
for building a new docker image.This file is written in a
popular, human-readable Markup Language called YAML.
• The docker build command processes this file generating a
Docker Image in your Local Image Cache, which you can then
start-up using the docker run command, or push to a
permanent Image Repository.
COMPONENTS OF DOCKERFILE
• FROM
FROM php:5.6-apache  The first part is the FROM command, which tells
us what image to base this off of. This is the multi-layered approach that makes
Docker so efficient and powerful. In this instance, it’s using the php:5.6-apache
Docker image, which again references a Dockerfile to automate the build process.
• MAINTAINER
The MAINTAINER instruction sets the Author field of the generated images.
• RUN
RUN a2enmod rewrite The next set of calls are the RUN commands. This is what runs
within the container at build time. From the calls, you can see that ModRewrite is enabled
(RUN a2enmod rewrite), and it then installs the php-gd and libraries required to run it.
CONT…
• VOLUME
VOLUME /var/www/html  This is the default volume we overrode in the last article. Specifying it
in the Dockerfile allows it to be externally mounted via the host itself or a Docker data container.
• ENV
ENV WORDPRESS_VERSION 4.2.2  This sets the environment variables, which can be used in
the Dockerfile and any scripts that it calls. These are persistent with the container too, so they can be referenced
at any time.
• COPY
COPY docker-entrypoint.sh /entrypoint.sh  The COPY command is simply as it sounds. It can copy
a file (in the same directory as the Dockerfile) to the container. You can do this for things like custom
configuration files or like in this instance, a file to run commands after the container has been set up.
CONT…
• ENTRYPOINT
The ENTRYPOINT specifies a command that will always be
executed when the container starts.
• CMD
The CMD specifies arguments that will be fed to the
ENTRYPOINT.
DOCKERFILE BUILD
• Example
From ubuntu
Maintainer "Debashis"
RUN apt-get update
RUN apt-get install vim -y
CMD /bin/echo "Hello! Welcome to docker Tutorial!!!“
• Build
sudo docker build -t demo:image01 .
sudo docker image ls
sudo docker run c2a181f68d62
DOCKER IMAGE PUSH
• Create the Repo in hub.docker.com
• docker login
• docker build -t nathdeb006/demo-image:image02 .
• docker image ls
• docker push nathdeb006/demo-image:image02
• Go to Docker hub and check

More Related Content

PPTX
Docker advance topic
PPTX
Academy PRO: Docker. Lecture 4
PPTX
Academy PRO: Docker. Lecture 3
PDF
Introduction to docker security
PPTX
Docker Workshop
PDF
dockerizing web application
PDF
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
PDF
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker
Docker advance topic
Academy PRO: Docker. Lecture 4
Academy PRO: Docker. Lecture 3
Introduction to docker security
Docker Workshop
dockerizing web application
JDO 2019: Tips and Tricks from Docker Captain - Łukasz Lach
Under the Hood with Docker Swarm Mode - Drew Erny and Nishant Totla, Docker

What's hot (20)

PDF
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
PPTX
Docker 1.11 Presentation
PDF
The state of the swarm
PDF
Docker Security Paradigm
PDF
Docker Compose to Production with Docker Swarm
PPTX
Docker in 30 minutes
PPTX
Academy PRO: Docker. Part 2
PPTX
Intro- Docker Native for OSX and Windows
PDF
Docker 1.11 @ Docker SF Meetup
PPTX
Docker Networking - Common Issues and Troubleshooting Techniques
PDF
An Updated Performance Comparison of Virtual Machines and Linux Containers
PDF
Introduction to Docker
PPTX
Academy PRO: Docker. Part 1
PDF
Docker Security in Production Overview
PDF
Red hat lvm cheatsheet
PDF
Docker introduction
PDF
Docker orchestration using core os and ansible - Ansible IL 2015
PPTX
KVM and docker LXC Benchmarking with OpenStack
PDF
Docker volume
PPTX
Getting Started with Docker
Plug-ins: Building, Shipping, Storing, and Running - Nandhini Santhanam and T...
Docker 1.11 Presentation
The state of the swarm
Docker Security Paradigm
Docker Compose to Production with Docker Swarm
Docker in 30 minutes
Academy PRO: Docker. Part 2
Intro- Docker Native for OSX and Windows
Docker 1.11 @ Docker SF Meetup
Docker Networking - Common Issues and Troubleshooting Techniques
An Updated Performance Comparison of Virtual Machines and Linux Containers
Introduction to Docker
Academy PRO: Docker. Part 1
Docker Security in Production Overview
Red hat lvm cheatsheet
Docker introduction
Docker orchestration using core os and ansible - Ansible IL 2015
KVM and docker LXC Benchmarking with OpenStack
Docker volume
Getting Started with Docker
Ad

Similar to Docker advance1 (20)

PPTX
moscmy2016: Extending Docker
PDF
PDF
Docker Containers - everything about docker Containers
PDF
Introduction to Docker - Learning containerization XP conference 2016
PDF
Docker: A New Way to Turbocharging Your Apps Development
PDF
手把手帶你學Docker 03042017
PPTX
Introction to docker swarm
PDF
Docker Essentials Workshop— Innovation Labs July 2020
PPTX
PPTX
Running Docker in Development & Production (DevSum 2015)
PDF
Docker, but what it is?
PDF
手把手帶你學 Docker 入門篇
PDF
Docker workshop 0507 Taichung
PDF
時代在變 Docker 要會:台北 Docker 一日入門篇
PPTX
Real World Experience of Running Docker in Development and Production
PPTX
Docker workshop
PPTX
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
PDF
Running the Oracle SOA Suite Environment in a Docker Container
PDF
Orchestrating Docker with OpenStack
PPTX
Docker-Presentation.pptx
moscmy2016: Extending Docker
Docker Containers - everything about docker Containers
Introduction to Docker - Learning containerization XP conference 2016
Docker: A New Way to Turbocharging Your Apps Development
手把手帶你學Docker 03042017
Introction to docker swarm
Docker Essentials Workshop— Innovation Labs July 2020
Running Docker in Development & Production (DevSum 2015)
Docker, but what it is?
手把手帶你學 Docker 入門篇
Docker workshop 0507 Taichung
時代在變 Docker 要會:台北 Docker 一日入門篇
Real World Experience of Running Docker in Development and Production
Docker workshop
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Running the Oracle SOA Suite Environment in a Docker Container
Orchestrating Docker with OpenStack
Docker-Presentation.pptx
Ad

More from Gourav Varma (20)

PPTX
Jenkins introduction
PPTX
Docker introduction (1)
PPTX
Aws day 4
PPTX
Aws day 3
PPTX
Aws day 2
PPTX
Ansible day 4
PPTX
Ansible day 3
PPTX
Adnible day 2.ppt
PPTX
Ansible day 1.ppt
PPTX
Version control git day03(amarnath dada)
PPTX
Version control git day02
PPTX
Version control git day01
PPTX
Dev ops
PPTX
Shell programming 2
PPTX
Introduction to linux
PPTX
Final terraform
PPTX
Version control git day03
PPTX
Version control git day02
PPTX
Version control git day01
PPT
Docker swarm
Jenkins introduction
Docker introduction (1)
Aws day 4
Aws day 3
Aws day 2
Ansible day 4
Ansible day 3
Adnible day 2.ppt
Ansible day 1.ppt
Version control git day03(amarnath dada)
Version control git day02
Version control git day01
Dev ops
Shell programming 2
Introduction to linux
Final terraform
Version control git day03
Version control git day02
Version control git day01
Docker swarm

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
master seminar digital applications in india
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Structure & Organelles in detailed.
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pharma ospi slides which help in ospi learning
Orientation - ARALprogram of Deped to the Parents.pptx
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
O7-L3 Supply Chain Operations - ICLT Program
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Anesthesia in Laparoscopic Surgery in India
A systematic review of self-coping strategies used by university students to ...
master seminar digital applications in india
RMMM.pdf make it easy to upload and study
Cell Structure & Organelles in detailed.
Microbial disease of the cardiovascular and lymphatic systems
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Microbial diseases, their pathogenesis and prophylaxis
VCE English Exam - Section C Student Revision Booklet
Supply Chain Operations Speaking Notes -ICLT Program

Docker advance1

  • 2. TOPICS • Docker Installation • Docker Network • Docker Volume • Dockerfile
  • 3. DOCKER INSTALLATION • Docker comes in 2 editions Docker CE (Community edition) and Docker EE (Enterprise Edition). Stable – gives you latest releases for general availability. Test – gives pre-releases that are ready for testing before general availability. Nightly – gives you the latest builds of work in progress for the next major release.
  • 4. INSTALL DOCKER ENGINE ON CENTOS • SET UP THE REPOSITORY $ sudo yum install -y yum-utils $ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo $ sudo yum-config-manager --enable docker-ce-nightly $ sudo yum-config-manager --enable docker-ce-test $ sudo yum-config-manager --disable docker-ce-nightly Install the latest version of Docker Engine $ sudo yum install docker-ce docker-ce-cli containerd.io $ sudo systemctl start docker $ sudo docker run hello-world
  • 5. CONT.. • Uninstall old versions $ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
  • 6. DOCKER NETWORKING • One of the reasons Docker containers and services are so powerful is that you can connect them together, or connect them to non-Docker workloads. • Network drivers 1. Bridge 2. Host 3. Overlay 4. Macvlan
  • 7. BRIDGE • The default network driver. • If you don’t specify a driver, this is the type of network you are creating. • Bridge networks are usually used when your applications run in standalone containers that need to communicate.
  • 9. TYPES OF BRIDGE • User-defined bridges • Default bridge
  • 10. USER-DEFINED BRIDGES • User-defined bridges provide automatic DNS resolution between containers: Containers on the default bridge network can only access each other by IP addresses, unless you use the --link option, which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias. • User-defined bridges provide better isolation: All containers without a --network specified, are attached to the default bridge network. This can be a risk, as unrelated stacks/services/containers are then able to communicate.
  • 11. CONT… • Containers can be attached and detached from user-defined networks on the fly: During a container’s lifetime, you can connect or disconnect it from user-defined networks on the fly. To remove a container from the default bridge network, you need to stop the container and recreate it with different network options. • Each user-defined network creates a configurable bridge: If your containers use the default bridge network, you can configure it, but all the containers use the same settings, such as MTU and iptables rules. In addition, configuring the default bridge network happens outside of Docker itself, and requires a restart of Docker.
  • 12. COMMAND • $ docker network create my-net  new network bridge creation • $ ifconfig  To verify the bridge configuration • docker create --name my-nginx --network my-net --publish 8080:80 nginx:latest docker network connect my-net my-nginx docker network disconnect my-net my-nginx docker network rm my-net  Remove the newly created bridge
  • 13. DOCKER VOLUMES • Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. • Volumes are easier to back up or migrate than bind mounts. • You can manage volumes using Docker CLI commands or the Docker API. • Volumes work on both Linux and Windows containers. • Volumes can be more safely shared among multiple containers. • Volume drivers let you store volumes on remote hosts or cloud providers, to encrypt the contents of volumes, or to add other functionality. • New volumes can have their content pre-populated by a container. • Command Flags –v or --mount
  • 14. CREATE AND MANAGE VOLUMES • Create a volume: docker volume create my-vol • List volumes: docker volume ls • Inspect a volume: docker volume inspect my-vol • Remove a volume: docker volume rm my-vol
  • 15. START A CONTAINER WITH A VOLUME • With flag --mount docker run -d --name devtest --mount source=myvol2,target=/app nginx:latest • With Flag –v docker run -d --name devtest -v myvol2:/app nginx:latest
  • 16. CONT… • Run the CMD, docker inspect devtest  Check the parameters • Removing CMD, docker container stop devtest docker container rm devtest docker volume rm myvol2
  • 17. START A SERVICE WITH VOLUMES docker service create -d --replicas=4 --name devtest-service --mount source=myvol2,target=/app nginx:latest $ docker service ps devtest-service docker inspect nginxtest docker service rm devtest-service
  • 18. READ-ONLY VOLUME docker run -d --name=nginxtest -v nginx-vol:/usr/share/nginx/html:ro nginx:latest docker run -d --name=nginxtest --mount source=nginx- vol,destination=/usr/share/nginx/html,readonly nginx:latest docker inspect nginxtest
  • 19. DOCKERFILE • A Dockerfile is a script/text configuration file that contains collections of commands and instructions that will be automatically executed in sequence in the docker environment for building a new docker image.This file is written in a popular, human-readable Markup Language called YAML. • The docker build command processes this file generating a Docker Image in your Local Image Cache, which you can then start-up using the docker run command, or push to a permanent Image Repository.
  • 20. COMPONENTS OF DOCKERFILE • FROM FROM php:5.6-apache  The first part is the FROM command, which tells us what image to base this off of. This is the multi-layered approach that makes Docker so efficient and powerful. In this instance, it’s using the php:5.6-apache Docker image, which again references a Dockerfile to automate the build process. • MAINTAINER The MAINTAINER instruction sets the Author field of the generated images. • RUN RUN a2enmod rewrite The next set of calls are the RUN commands. This is what runs within the container at build time. From the calls, you can see that ModRewrite is enabled (RUN a2enmod rewrite), and it then installs the php-gd and libraries required to run it.
  • 21. CONT… • VOLUME VOLUME /var/www/html  This is the default volume we overrode in the last article. Specifying it in the Dockerfile allows it to be externally mounted via the host itself or a Docker data container. • ENV ENV WORDPRESS_VERSION 4.2.2  This sets the environment variables, which can be used in the Dockerfile and any scripts that it calls. These are persistent with the container too, so they can be referenced at any time. • COPY COPY docker-entrypoint.sh /entrypoint.sh  The COPY command is simply as it sounds. It can copy a file (in the same directory as the Dockerfile) to the container. You can do this for things like custom configuration files or like in this instance, a file to run commands after the container has been set up.
  • 22. CONT… • ENTRYPOINT The ENTRYPOINT specifies a command that will always be executed when the container starts. • CMD The CMD specifies arguments that will be fed to the ENTRYPOINT.
  • 23. DOCKERFILE BUILD • Example From ubuntu Maintainer "Debashis" RUN apt-get update RUN apt-get install vim -y CMD /bin/echo "Hello! Welcome to docker Tutorial!!!“ • Build sudo docker build -t demo:image01 . sudo docker image ls sudo docker run c2a181f68d62
  • 24. DOCKER IMAGE PUSH • Create the Repo in hub.docker.com • docker login • docker build -t nathdeb006/demo-image:image02 . • docker image ls • docker push nathdeb006/demo-image:image02 • Go to Docker hub and check