Docker
Docker
Containers
What is Container?
Containers
• Operating-System-Level Virtualization
• Allows to run multi-tenant user space instances within a different
context than that of the host Operating System
– Allow us to be able to create “images” of an application runtime and
then run one or many “instances” of that image on our systems
– Even if the Host does not have the required software installed to
actually run the application inside the image
– The requirements are shipped along with the Image
1
2/1/2023
What is Container?
Containers
• Operating-System-Level Virtualization
What is Container?
• Containers is a lightweight virtualization technology acting
as an alternative to hypervisor virtualization
– Bundle any application in a container and run it without
thinking of dependencies, libraries, and binaries
– All containers share the same host operating system
– Multiple containers get created for every type of application
making them faster but without wasting the resources
2
2/1/2023
What is Container?
• Supports multiple containers with different application
requirements and dependencies to run on the same host
– As long as they have the same operating system requirements
Before Container
The problem
• Assume three different Python-based applications that needs
to be hosted on a single server (which could either be a
physical or a virtual machine)
– Each of these applications makes use of a different version of
Python, as well as the associated libraries and dependencies, differ
from one application to another
– Since we cannot have different versions of Python installed on the
same machine
• This prevents us from hosting all three applications on the same
computer
3
2/1/2023
Before Docker
The Solution
• Three physical machines, or a single physical machine,
which is powerful enough to host and run three virtual
machines on it
• Both the options would allow us to install different versions
of Python on each of these machines, along with their
associated dependencies
4
2/1/2023
5
2/1/2023
What is Docker?
• Docker is a containerization platform that packages your
application and all its dependencies together in the form of
containers to ensure that your application works seamlessly in
any environment
• Docker is a software platform that simplifies the process of
building, running, managing and distributing applications
– It does this by virtualizing the operating system of the computer on
which it is installed and running
What is Docker?
• A Docker Container have a virtual copy of the process table,
network interface(s), and the file system mount point(s)
– These have been inherited from the operating system of the host
on which the container is hosted and running
– Whereas the kernel of the host’s operating system is shared
across all the containers that are running on it
– This allows each container to be isolated from the other present
on the same host
6
2/1/2023
7
2/1/2023
• The REST API specifies how the applications can interact with
the Server, and instruct it to get their job done
• The Client is nothing but a command line interface, that
allows users to interact with Docker using the commands
Docker Architecture
8
2/1/2023
Docker Architecture
Docker Architecture
Docker Image
• A recipe/template that contains the application, and all the
dependencies required to run that application on Docker
Docker Container
• A running instance of the Docker Image
Docker Registry
• A repository for Docker images which is used for creating
Docker containers
• We can use a local/private registry or the Docker hub,
which is the most popular social example of a Docker
repository
9
2/1/2023
Docker Editions
• Docker is available in 2 different editions, as listed below:
– Community Edition (CE)
– Enterprise Edition (EE)
10
2/1/2023
Installing Docker
https://docs.docker.com
Docker Commands
docker create
• Allows us to create a new container
docker create IMAGE
Example
$ docker create mysql
11
2/1/2023
Docker Commands
docker ps
• Allows us to view all the containers that are running on the
Docker Host
$ docker ps
$ docker ps –a
• Display all the containers that were created on this Docker
Host - running or exited
Docker Commands
docker start
• Starts any stopped container(s)
docker start CONTAINER ID/NAME
Example
$ docker start 30986
docker stop
• Stops any running container(s)
docker stop CONTAINER ID/NAME
Example
$ docker start 30986
12
2/1/2023
Docker Commands
docker run
• First creates the container, and then it starts the
container
• In short, this command is a combination of the docker
create and the docker start command
docker run IMAGE [commands] [arguments]
Example
$ docker run ubuntu
Docker Commands
docker rm
• If we want to delete a container, we use the docker
rm command
docker rm CONTAINER ID/NAME
docker images
• Lists out all the Docker Images that are present on
your Docker Host
$ docker images
13
2/1/2023
Docker Commands
docker rmi
• Allows us to remove an image(s) from the Docker Host
14