Professional Documents
Culture Documents
What is Virtualization
What is Containerization?
Containerization is a type of Virtualization which brings virtualization to the operating system level.
What is Docker?
Docker is a platform which packages an application and all its dependencies together in the form of
containers. This containerization aspect of Docker ensures that the application works in any
environment.
As you can see in the diagram, each and every application runs on separate containers and has its
own set of dependencies & libraries. This makes sure that each application is independent of other
applications, giving developers surety that they can build applications that will not interfere with one
another.
A developer can build a container having different applications installed on it and give it to the QA
team. Then the QA team would only need to run the container to replicate the developer’s
environment.
Dockerfile: A Dockerfile is a text document which contains all the commands that a user can call on
the command line to assemble an image. So, Docker can build images automatically by reading the
instructions from a Dockerfile. You can use docker build to create an automated build to execute
several command-line instructions in succession.
Docker Image: In layman terms, Docker Image can be compared to a template which is used to create
Docker Containers. So, these read-only templates are the building blocks of a Docker Container. You
can use docker run to run the image and create a container.
Docker Images are stored in the Docker Registry. It can be either a user’s local repository or a public
repository like a Docker Hub which allows multiple users to collaborate in building an application.
Docker Container: Docker Container is a running instance of a Docker Image as they hold the entire
package needed to run the application. So, these are basically the ready applications created from
Docker Images which is the ultimate utility of Docker.
Docker Compose & Docker Swarm
Docker Compose is a YAML file which contains details about the services, networks, and volumes for
setting up the Docker application. So, you can use Docker Compose to create separate containers,
host them and get them to communicate with each other. Each container will expose a port for
communicating with other containers.
Docker Swarm is a technique to create and maintain a cluster of Docker Engines. The Docker engines
can be hosted on different nodes, and these nodes, which are in remote locations, form a Cluster
when connected in Swarm mode.
Step 3: Create a folder in which you can create a DockerFile and change the current working directory
to that folder.
mkdir images
cd images
Step 4.1: Now create a Dockerfile by using an editor. In this case, I have used the nano editor.
Nano Dockerfile
Step 4.2: After you open a Dockerfile, write the Dockerfile as follows.
FROM ubuntu:latest
MAINTAINER Sahiti (email@domain.com)
RUN apt-get update
RUN apt-get install -y nginx
ENTRYPOINT ["/usr/sbin/nginx","-g","daemon off;"]
EXPOSE 80
Step 4.3: Once you are done with that, just save the file.
Step 7: Now to create a container based on this image, by running the following command:
docker run -it -p port_number -d image_id
Where -it is to make sure the container is interactive, -p is for port forwarding, and -d to run the
daemon in the background.
Step 8: Now you can check the created container by using the following command:
docker ps
https://www.edureka.co/blog/docker-explained/
Lecture Recap
Virtual Machines are slow and take a lot of time to boot.
Containers are fast and boots quickly as it uses host operating system and shares the relevant
libraries.
Containers do not waste or block host resources unlike virtual machines.
Containers have isolated libraries and binaries specific to the application they are running.
Containers are handled by Containerization engine.
Docker is one of the containerization platforms which can be used to create and run
containers.