Module 4 - Containerization - Docker
Module 4 - Containerization - Docker
AGENDA
Virtualization
Containerization
Introduction to Docker
Hypervisor
Container Engine
Operating System
Hardware
Developers when run the code on their system, it would run perfectly. But the same code
would not run on the operations team’s system.
Works fine on
my system!
Doesn’t work
on my system.
Faulty code!
Developer Operations/
Testing
The problem was with the environment the code was being run in. Well, a simple answer
could be, why not give the same VM to the operations/testing team to run the code.
Developer Operations/
Testing
With containers, all the environment issues were solved. The developer could easily wrap
their code in a lightweight container and pass it on to the operationsteam.
Here is the
container. I
have wrapped
Wow, it’s hardly 30
my code in.
MB. Awesome,your
code works just
fine!
Developer Operations/
Testing
Pull
run
Docker Hub Push
stop
delete
Container Stages
Docker Hub
Docker Hub is a central public docker registry.
Containers
Docker Volumes
Docker File
© Copyright. All Rights Reserved.
COMPONENTS OF DOCKER ECOSYSTEM
Docker Hub
Docker Engine is the heart of the docker ecosystem.
Containers
Docker Volumes
Docker File
© Copyright. All Rights Reserved.
COMPONENTS OF DOCKER ECOSYSTEM
Docker Hub
Docker Image is like the template of acontainer.
It is created inlayers.
Docker Engine
Any new changes in the image results in creating a
new layer.
Docker Images
One can launch multiple containers from a single
docker image.
Containers
Docker Volumes
Docker File
© Copyright. All Rights Reserved.
COMPONENTS OF DOCKER ECOSYSTEM
Docker Hub
A Docker Container is a lightweight software
environment.
Containers
Docker Volumes
Docker File
© Copyright. All Rights Reserved.
COMPONENTS OF DOCKER ECOSYSTEM
Docker Hub
Docker Containers cannot persist data.
Docker Volumes
Docker File
© Copyright. All Rights Reserved.
COMPONENTS OF DOCKER ECOSYSTEM
Docker Hub
Dockerfile is a YAML file, which is used to create
custom containers
Docker Engine
It can include commands that have to be run on the
command line
Docker Images This Dockerfile can be used to build custom
container images
Containers
Docker Volumes
Dockerfile
© Copyright. All Rights Reserved.
INSTALLING
DOCKER
docker --version
This command helps you know the installed version of the docker software on your system.
This command helps you pull images from the central docker repository.
docker images
This command helps you in listing all the docker images downloaded on your system.
docker ps
This command helps in listing all the containers which are running in the system.
docker ps -a
If there are any stopped containers, they can be seen by adding the -a flag in this command.
For logging into/accessing the container, one can use the exec command.
docker rm <container-id>
1. Navigate to https://hub.docker.com
4. Click on Sign up
Let’s try to accomplish the following example with a container and see how we can
commit this container into an image.
Commit these
changes to the
container
apt-get update
apt-get install apache2
The username has to match with the username you created on DockerHub.
The container-name canbe anything.
docker login
devopsdemo/apache
[docker.io/devopsdemo/apache]
devopsdemo
docker pulldemo/apache
devopsdemo/apache
A Dockerfile is a text document that contains all the commands a user could call on the command line to
assemble an image. Using the docker build, users can create an automated build that executes several
command-line instructions in succession.
RUN Example
FROM ubuntu
CMD
Dockerfile
ENTRYPOINT
ENV
RUN Example
FROM ubuntu
ADD . /var/www/html
CMD
Dockerfile
ENTRYPOINT
ENV
RUN Example
FROM ubuntu
RUN apt-get update
CMD RUN apt-get -y installapache2
ADD . /var/www/html
ENTRYPOINT
ENV
Dockerfile
RUN Example
FROM ubuntu
RUN apt-get update
CMD RUN apt-get -y installapache2
ADD . /var/www/html
CMD apachectl –D FOREGROUND
ENTRYPOINT
ENV
Dockerfile
RUN Example
FROM ubuntu
RUN apt-get update
CMD RUN apt-get -y installapache2
ADD . /var/www/html
ENTRYPOINT apachectl –DFOREGROUND
ENTRYPOINT
ENV
Dockerfile
RUN Example
FROM ubuntu
RUN apt-get update
CMD RUN apt-get -y installapache2
ADD . /var/www/html
ENTRYPOINT apachectl –DFOREGROUND
ENTRYPOINT ENV name Devops Tutorial
ENV
Dockerfile
Example
FROM ubuntu
RUN apt-get update
RUN apt-get -y installapache2
ADD . /var/www/html
ENTRYPOINT apachectl -DFOREGROUND
ENV name Devops Tutorial
Dockerfile
demo/apache