Introduction to Docker presented by MANAOUIL Karim at the Shellmates's Hack.INI event. The teams deployed were assisted to deploy a Python Flask application behind an Nginx load balancer.
2. What is Docker ?
● System level virtualisation
technology.
● Produces Lightweight virtual
machines.
● Isolate processes from the host
environment (fs isolation, net
isolation, id isolation).
4. Why Docker ?
● Package applications and their dependencies
in one portable abstract unit.
● Shortens deployment time and effort.
● Ease application scaling on a very large
compute domain.
● New perspectives : Micro-services based
architecture.
6. Creating the first Docker Container
● Pull the Ubuntu image from the registry.
$ docker image pull ubuntu
● Start a container based on the Ubuntu image
$ docker container run -it –-name ubuntu ubuntu /bin/sh
7. Listing images and containers
● List images
$ docker images
$ docker image ls
● List running containers
$ docker ps
$ docker container ls
● List all containers
$ docker ps -a
$ docker container ls -a
8. Start in detached mode
● Add -d option to docker run
$ docker run -dit –-name ubuntu ubuntu /bin/sh
● To leave container without exiting it
CTRL + P + Q
● To connect the terminal to the detached container
$ docker attach {id} | {NAME}
9. Networking
● Default mode is bridge : All containers
and host are connected to a virtual
switch in the same subnet 172.17.0.0/16
● List network drivers
$ docker network ls
● Show information of a network driver
$ docker network inspect bridge
10. Deploy a real application
● We will deploy Flask application
● Start from a base image of Ubuntu
with Python and Flask installed
● Create a new image and add our
custom application.
11. Dockerfile
● It is a text file that contains a sequence of
instruction to build an image from an existing
one.
● Build the image with
$ docker build -t <tag>
● Launch the container
$ docker run -d –-name app <tag>
12. Micro-services and scaling
● What if we have multiple services and
we want to automate the process of
deployment ?
● Or What if we want to scale up our
application with ease ?
13. Docker-compose
● Docker-compose is a mean to describe
the deployment of multiple
containers/services with one single
yml file.
● It eases the scaling up of an
application.
15. Docker-compose
● Bring up the services with
$ docker-compose up
●
Describe you services with docker-compose.yml
●
Three web applications
●
One nginx reverse proxy