DOCKER
AGENDA
• Introduction to Docker?
• Docker Installation and Setup
• Key Docker Concepts
• Creating your first Docker Image
• Docker commands and Management
• Docker Compose
Overview of Docker and
containerization
What is a Container?
A way to package application with all the necessary dependencies and
configuration .
That package is portable artifact, easily shared and moved around between a
development team or development and operations team.
Makes development and deployment more efficient.
Where do Containers live?
Containers live in Container Repository( Storage for Containers).
Many companies have their own private repositories where they host or the
way they store all the containers.
Public Repository for Docker Containers called DOCKER HUB.
How did we develop applications before the containers?
How did we develop applications after the usage of containers?
How did we deploy applications before the containers?
How did we deploy applications after the usage of containers?
What is a Container ?
• Container is made up off layers of images.
• At the base of the image ( most of the containers ) have Linux Base Image
because small in size. ( Alpina version or Linux distribution)
• On top of the base image, we do have application image and rest all
images are placed in between them.
• hub.docker.com ( public repository for docker images )
• docker run image_name ( it downloads the image and creates a
container)
• docker pull image_name ( just downloads the image )
• docker run image_name:version_no ( to specify particular version )
• docker ps ( to list the docker images )
To run container in background and prints the container ID :: docker run –d image_name (-
d / --detach )
How Operating System is made
up of ?
1. Operating System have two layers , OS kernel and application layer.
2. Kernel is the part that communicates with the hardware components like CPU and
memory , etc.
3. Applications run on the kernel layer.
Docker vs Virtualization
4. Docker and Virtual Machines are both virtualization tools.
Virtualization Tools
DO CK ER V I RT UA L M ACHI N ES
• SIZE : Docker images are • Gigabytes
smaller in size ( megabytes )
• SPEED : Docker containers
• Its slow compared to Docker
start and run much fast
• VM of any OS can run on any
• COMPATIBILITY : possible by
OS host
Docker Desktop/Docker
ToolBox
Installation of Docker
Docker Image
To list all Docker images :: docker images
To list running containers :: docker ps
Docker Registries
Image Versioning
Docker Commands
To view logs from service running inside the container :: docker
logs container_ID
To stop one or more running containers :: docker stop
container_ID container_ID
To list all the stopped and running containers :: docker ps -a / --all
To re-start a stopped container :: docker start container_ID
To specify the container name :: docker run --name -d
container_name
Port Binding
How to access the container ??
Application inside container runs in an isolated Docker network. (
we cant access it from our local computer )
We need to expose the container port to the host ( the machine
the container runs on)
Port Binding :: bind the containers port to the host’s port to
make the service available to the outside world.
docker run –d –p host port_number:container port_number
port binding
--publish ( publish a container’s port to the host )
docker run --name -d container_name –publish host port_number:container
port_number ( to specify container name )
Private Docker Registries
Nexus ( popular artifact repository manager )
DockerHub
Registry vs Repository
Docker Registry :: A service providing storage. Can be hosted by
a third party , like AWS . Collection of repositories .
Docker Repository :: collection of related images with same name but different versions.
DockerHub is a registry.
On DockerHub , you can host private or public repositories for your applications.
Dockerfile
Companies create custom images for their applications
Docker Compose
Docker Compose is used for running multiple containers as a
single service.
Here , containers run in isolation but can interact with each
other.
All Docker Compose files are YAML files. (xml based language )
In Docker Compose , a user can start all the services (containers)
using a single command.