Introduction to
Docker
HELLO!
I am Nilesh Jayanandana
Senior Software Engineer at Platformer
twitter.com/nilesh_93
medium.com/nilesh93.j
linkedin.com/in/nilesh93
Pre requisites
Couple of concepts you need to be familiar with
Prerequisite concepts needed to know
✘ How to deploy an application to a server
✘ Scaling applications
A history Lesson
Journey through the evolution of Ops
A History Lesson: Dark Ages
One Physical Server → One Application
Limitations
✘ Slow deployment times
✘ Huge costs
✘ Difficult to scale
✘ Wasted resources
✘ Difficult to migrate
A History Lesson: Hypervisor based Virtualization
✘ One physical Server → multiple VMs
✘ One VM → One Application
Benefits of VMs
✘ Better resource pooling
✘ Easier to scale
✘ Cloud service providers (AWS, Google, Azure)
Limitations of VMs
✘ Wasted resources for Guest OS
✘ Portability not guaranteed
✘ More VMs you run, more resources needed.
A history lesson: Present Day
Containers
Containers are a solution to
the problem of how to get
software to run reliably
when moved from one
computing environment to
another.
Containers vs VMs
Containers vs VMs
✘ Similar resource isolation and allocation
benefit.
✘ Containers virtualize the operating system
instead of hardware.
✘ Containers are more portable and efficient.
Mixing VMs and Containers together
What is Docker?
The tool used to containerize applications
https://www.docker.com/products/docker-desktop
Common problems SLIIT Undergrads Have
✘ Unable to setup your application in a friend’s
machine
✘ Cannot run multiple applications configured
on same port
Solution - Containerizing Applications
✘ Portability
✘ Isolation of processes
✘ Lightweight
✘ Modularity
✘ Simplicity
✘ Security
Simply put ….
Developer Use Cases
✘ Use docker for local app development
✘ Deploy your application in any Server without
an issue
✘ Easily scale
✘ Ensure Availability
Many more...
Docker Basics
✘ Dockerfile
✘ Images
✘ Containers
✘ Registry
✘ Engine
Docker Images and Containers
Things to consider
✘ Size of the container (Depends on base image) -
smaller the better
✘ Ports exposed
✘ Make application stateless as possible
✘ Remove sensitive information from code and get
from env
Dockerfile
The config file used to build docker images
✘ FROM
✘ RUN
✘ WORKDIR
✘ COPY
✘ EXPOSE
✘ CMD
Demo
Couple of important commands to remember
✘ Docker image ls - list images
✘ Docker container ls - list containers
✘ Docker build -t <any name> . - build from Dockerfile
✘ Docker run <tag name> - run a container from image
Flags to be passed to Docker run
✘ -p <host>:<container> - port binding
✘ -v <absolute-host-path>:<container-path> -
Volume binding
✘ -it <tag name> /bin/sh - access shell of
container
Complete Example
1. docker build -t my-app .
2. docker run \
-p 8080:3000 \
-v $(pwd):/app \
-e SAMPLE_ENV=sliit \
-it my-app /bin/sh
***Remove the letters in blue color if you don’t want to access the shell of the container
What’s Next?
✘ Container Orchestration (eg: Kubernetes)
✘ CI/CD
✘ Scaling
✘ Multi Stage Builds
And many more...
THANKS!
Any questions?
You can find me at
twitter.com/nilesh_93
medium.com/nilesh93.j
linkedin.com/in/nilesh93