Professional Documents
Culture Documents
Container
An abstraction of a machine
(physical hardware)
Hypervisors
- Virtual Box
- VMware
- Hyper-V (windows only)
Virtual Machine
Run applications in
isolation
Virtual Machine – Problems
- Each VM needs a full-blown OS
- Slow to start
- Resource intensive
Docker Containers vs Virtual Machine
Docker Containers
- Allow running multiple apps in
isolation
- Are lightweight
- Use OS of the host
- Start quickly
- Need less hardware resources
The bad old days
Applications run businesses.
If applications break, businesses break. Sometimes they even go bust.
These statements get truer every day!
Docker Advantages
- Docker for Everyone
- Environment Isolation
- OS Independent Apps
- Rapid Development & Deployment
- Scalability & Flexibility Made Easier
- No More Security Issues
- Ship Anytime, Anywhere
- Dependency Management Made Easier
Docker Architecture
The 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.
The 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.
Docker Client & Docker Server
- Docker Client (Docker CLI)
- Tool that we are going to issue commands to
- Link: https://docs.docker.com/desktop/windows/install/#system-requirements
Docker Desktop on
Windows 10
WSL 2 backend
Using the Docker Client
~$ docker version
~$ docker info
~$ docker run hello-world
Using the Docker Client
Your Computer Docker Hub
Single file with
everything needed
docker run hello-world Docker Client hello-word to run one specific
program
redis
Kernel
Chrome NodeJS
Kernel
Chrome NodeJS
Kernel
Segment of HD Python v2 Python v3 Segment of HD
for Chrome Hard Disk for Node
Operating System
Needs Python v2 Needs Python v3
Chrome NodeJS
Chrome NodeJS
Chrome
Kernel
Running
Process
Image
FS Snapshot Startup Command
Kernel
Chrome Python > Run Chrome
Hard Drive
Container *
Container
Running
Process
Image
FS Snapshot Startup Command
Kernel
Chrome Python > Run Chrome
Chrome Python
Container *
Container
Running
Chrome Process
Image
FS Snapshot Startup Command
Kernel
Chrome Python > Run Chrome
Chrome Python
Docker Container
Linux Kernel
MacOS / Windows
Reference Name of
the Docker image to use
Client for this
container
Manipulating Containers with the Docker CLI
~$ docker run hello-world Container
Running
hello-world Process
Image
FS Snapshot Startup Command
Kernel
hello-world > Run hello-world
Try to create
and run a Default command
container override
Reference Name of
the Docker image to use
Client for this
container
Manipulating Containers with the Docker CLI
~$ docker run busybox echo hi
~$ docker run busybox ls
Manipulating Containers with the Docker CLI
~$ docker run busybox ls Container
Running
ls Process
Busybox Image
FS Snapshot Startup Command Kernel
bin dev etc
> ??? Network CPU RAM
home proc root
bin dev etc
Hard drive segment
home proc root for this process
Listing Running Containers
~$ docker ps
List all running
containers
docker ps
Reference
the Docker
Client
Listing Running Containers
~$ docker ps
~$ docker run busybox ping google.com
~$ docker ps
~$ docker ps --all
Container Lifecycle
~$ docker run
Create a
docker create <image name>
Container
Reference Name of image to use
the Docker Client for this container
Try to start
the container
Start a
docker start <container id>
Container
Reference ID of the container to
the Docker Client start
Container Lifecycle – Create a Container
Container
~$ docker create
Running
Process
Image
FS Snapshot Startup Command Kernel
hello-world > Run hello-world
Network CPU RAM
Image
FS Snapshot Startup Command Kernel
hello-world > Run hello-world
Network CPU RAM
Get Logs
Stop or Kill
a Container
docker stop <container id>
Running
stop SIGTERM ping google.com
Process
Kernel
Network CPU RAM
Running
stop SIGKILL ping google.com
Process
Kernel
~$ docker start <c_id> Network CPU RAM
Application Image
Dockerfile
Development Workflow – Image
- A cut-down OS
- A runtime environment
- Application files
- Third-party libraries
- Environment variables
Development Workflow – Container
Image Container
Development Workflow – Container
~$ docker run hello-world Container
Running
hello-world Process
Hello-World Image
FS Snapshot Startup Command
Kernel
hello-world > Run hello-world
Configuration to define
how our container
should behave
Creating Docker Images
Creating a Dcokerfile
Goal
Creating Docker Images
~$ mkdir node-image
~$ cd node-image
~$ node-image > code .
~$ app.js
~$ Dockerfile
Creating Docker Images