Docker Modules
Docker Modules
Docker - I
Components of Introduction to
04 Docker
08 Dockerfile
Hypervisor
CPU 10%
Imagine Software A running on Server A which has Ubuntu running on it. This software can
only run in the Ubuntu environment.
Some time later, we needed Software B which can only run on Windows. Therefore, we
had to buy and run a Server B which had windows running on it. The software took only
10% of the CPU resources.
CPU 20%
Server A running
Software A Software B Windows and
Ubuntu
Windows and Ubuntu OS now are running on the same server in parallel using the Virtualization
technology. This accounts for better CPU utilization and cost savings!
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 operations team.
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
Docker Hub
run
Push
stop
delete
Container Stages
Containers
Docker Volumes
Docker File
© Copyright 2019 IntelliPaat, All rights reserved
Components of Docker Ecosystem
Docker Hub
Docker Engine is the heart of the docker ecosystem.
Containers
Docker Volumes
Docker File
© Copyright 2019 IntelliPaat, All rights reserved
Components of Docker Ecosystem
Docker Hub
Docker Image is like the template of a container.
It is created in layers.
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 2019 IntelliPaat, All rights reserved
Components of Docker Ecosystem
Docker Hub
A Docker Container is a lightweight software
environment.
Containers
Docker Volumes
Docker File
© Copyright 2019 IntelliPaat, All rights reserved
Components of Docker Ecosystem
Docker Hub
Docker Containers cannot persist data.
Docker Volumes
Docker File
© Copyright 2019 IntelliPaat, 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 2019 IntelliPaat, 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 can be anything.
docker login
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.
ADD
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 install apache2
ADD . /var/www/html
ENTRYPOINT
ENV
Dockerfile
RUN Example
FROM ubuntu
RUN apt-get update
CMD RUN apt-get -y install apache2
ADD . /var/www/html
CMD apachectl –D FOREGROUND
ENTRYPOINT
ENV
Dockerfile
RUN Example
FROM ubuntu
RUN apt-get update
CMD RUN apt-get -y install apache2
ADD . /var/www/html
ENTRYPOINT apachectl –D FOREGROUND
ENTRYPOINT
ENV
Dockerfile
RUN Example
FROM ubuntu
RUN apt-get update
CMD RUN apt-get -y install apache2
ADD . /var/www/html
ENTRYPOINT apachectl –D FOREGROUND
ENTRYPOINT ENV name Devops Intellipaat
ENV
Dockerfile
Example
FROM ubuntu
RUN apt-get update
RUN apt-get -y install apache2
ADD . /var/www/html
ENTRYPOINT apachectl -D FOREGROUND
ENV name Devops Intellipaat
Dockerfile
A. True
B. False
A. True
B. False
A. Docker save
B. Docker commit
C. Docker push
D. None of these
A. Docker save
B. Docker commit
C. Docker push
D. None of these
3. ______ is a service from Docker which provides registry capabilities for public and
private Docker Images.
A. Docker Cloud
B. Docker Community
C. Docker Hub
D. None of these
3. ______ is a service from Docker which provides registry capabilities for public and
private Docker Images.
A. Docker Cloud
B. Docker Community
C. Docker Hub
D. None of these
A. True
B. False
A. True
B. False
5. Containers, running on the same machine, share the underlying kernel of the host OS.
A. True
B. False
5. Containers, running on the same machine, share the underlying kernel of the host OS.
A. True
B. False