Docker Containers

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Docker

Containers
Problematic
Let’s take the example of a company that’s developing a Java Application.

A developer uses GlassFish as The tester also has to install GlassFish The system admin must also install GlassFish
an Application Server on their system on their system to deploy the application

Developer Tester System Admin

The installation of GlassFish must be done separately on three different computers due to the difference in computer
environments
Solution?
Use Docker
Containers!
Build Ship Run

Developer Container Tester

Containers allow you to package an application and its dependencies without having to install software locally on each
device.
Introduction to Docker
Introduction to
Docker
What is Docker?
• Docker is an open platform for developing, shipping, and
running applications.

• Docker enables you to separate your applications from your infrastructure


so you can deliver software quickly.

• By taking advantage of Docker’s methodologies for shipping, testing, and


deploying code quickly, you can significantly reduce the delay between
writing code and running it in production.
Introduction to
Docker
Docker and Containers?

• Docker provides the ability to package and run an application in a


loosely isolated environment called a container.

• The isolation and security allow you to run many containers simultaneously
on a given host.

• This means you can run more containers on a given hardware combination
than if you were using virtual machines. You can even run Docker
containers within host machines that are actually virtual machines!
Introduction to
Docker
What’s a container?
• A Container is an executable
software package that includes all
dependencies (frameworks,
libraries, etc…) required to
execute an application.

• Containers do not contain


operating system images. This
makes them more lightweight and
portable

• With Docker Containers,


applications can work effectively
Why use
Docker?
Why use Docker?
Docker vs VMs vs Standard Application Deployment

Standard Machines Virtual Machines Docker Containers


Why use Docker?
Limitations of Standard Application Deployment

• No isolation between
different applications

• Slow deployment times


• Huge costs if you decide to opt
for one server for each
application.

• Wasted ressources
• Difficult to migrate
Why use
Docker?
Limitations of VMs
• Each VM requires CPU
Allocation, RAM
Allocation, Storage…

• The more VMs you run, the


more ressources you need.

• Guest OS means wasted


ressources.

• Application portability
not guaranteed.
Why use Docker?
Key Benefits of Docker Containers

Secur
e

Applications run in Portabl


isolation e

Occupies less Short boot-up time


space

Lightweight
Docker Objects
Docker
Objects
Docker Images
• A Docker Image is a read-only template
with instructions for creating a Docker
container.
• Often, an image is based on another
image, with some additional
customization. For example, you
may build an image which is based
on
the ubuntu image, but installs the
Apache web server and your
application, as well as the
configuration details needed to make
your application run.
• You might create your own images
Docker Objects
How to create Docker Images? (Dockerfile)

• To build your own image, you create


a Dockerfile with a simple syntax for
defining the steps needed to create
the image and run it.
• Each instruction in a Dockerfile
creates a layer in the image. When
you change the Dockerfile and
rebuild the image, only those
layers which have changed are
rebuilt.
• This is part of what makes images so Dockerfil
lightweight, small, and fast, when e
compared to other virtualization
technologies.
Docker
Objects
Docker Containers
• A container is a runnable instance of
an image.
• You can create, start, stop, move,
or delete a container using the
Docker API or CLI.
• A container is defined by its image as
well as any configuration options you
provide to it when you create or
start it.
• When a container is removed, any
changes to its state that are not
stored in persistent storage
Docker
Objects
In other words…

BUILD RUN

Dockerfil Docker Image Docker Container


e
How does Docker work?
How does Docker
work?
Docker Engine
Docker Engine is a client-server
application with these major components:
• A server which is a type of long-running program
called a daemon process (the dockerd command).

A REST API which specifies interfaces that
programs can use to talk to the daemon and

instruct it what to do.
A command line interface (CLI)
Theclient (the docker
CLI uses command).
the Docker REST API to control
or interact with the Docker daemon through
scripting or direct CLI commands.
The daemon creates and manages
Docker objects, such as images and
containers.
How does Docker
work?
Docker Architecture
• Docker uses a client-server
architecture.

• The Docker client talks to the


Docker daemon, which does the
heavy lifting of building,
running, and distributing your
Docker containers.

• The Docker daemon can


either run in the same system
as the Docker client, or on a
remote host.
How does Docker
work?
Docker Daemon
• The Docker daemon
(dockerd) listens for Docker
API requests and manages
Docker objects such as
images, containers, networks,
and volumes.

• A daemon can also


communicate with other
daemons to manage Docker
services.
How does Docker
work?
Docker Client
• The Docker client (docker) is
the primary way that many
Docker users interact with
Docker.

• When you use commands such


as docker run, the client
sends these commands to
dockerd, which carries them
out.

• The docker command uses the


Docker API. The Docker client can
communicate with more than one
daemon.
How does Docker
work?
Docker Registries
• A Docker registry stores Docker
images.

• Docker Hub is an example of a


public registry that anyone can
use, and Docker is configured to
look for images on Docker Hub
by default.

• You can even run your own


private registry.
How does Docker
Hands-on
work? with Docker

• To build a Docker Image:


docker build -t IMAGE-NAME:TAG PATH (Path to the
Dockerfile)

• To push a Docker Image to a registry:


docker push IMAGE-NAME:TAG

• To pull a Docker Image from a registry:


docker pull IMAGE-NAME:TAG

• To run a new container from an Image:


docker run IMAGE-NAME:TAG

You might also like