A repository containing a short tutorial for Docker (with Python).

Overview

Docker Tutorial for IFT 6758 Lab

image

In this repository, we examine the advtanges of virtualization, what Docker is and how we can deploy simple programs on Docker.

Firstly, we will start by listing some advantages of virtualization. We can discuss them as follows:

  • Minimize hardware costs (Multiple virtual servers on one hardware unit).
  • Easily for HA (High Availability) And Disaster Recovery (DR).
  • Easier to save money and save energy, could be potentially greener.

Problems with Virtualization:

  • Hard to maintain each OS, installation, HyperVisor and host OS compatibility issues, and HyperVisor - container issues.
  • Costly and might take IT/Programming effort.
  • We might need a high storage overhead, even lightweight OSs with all tools installed can bulk up to a high size.

image

Solution?

  • Use containers!

Container definition:

  • is a runnable instance (or sandbox) of an image.
  • can be run on local machines, virtual machines or deployed to the cloud.
  • is portable (can be run on any OS).
  • Containers are isolated from each other and run their own software, binaries, and configurations.

Methodology:

  • These applications share a parent application and its overhead.
  • These apps can run separately, and we can avoid multithreading issues, deadlock issues and other issues with RPCs that may arise.
  • They can't access each other's resources, and they are like apartments in a complex.

Container Architecture:

image

  • Multiple containers run on the same machine virtual / physical machine.
  • All containers share the same OS and Kernel.
  • We can micro-manage processes, and have a higher level and more fine-grained access.
  • We can stop processes using the power of the host OS, and we can even save/move states as we need.
  • We can run containers inside VM! It's interesting as we can combine the power of both if we have a very specialized applicaiton.
  • Higher security as we are working with a very simple isolated block of code.

Compute Comparision:

image

Docker:

Standard definition:

"An open-source project that automates the deployment of software applications inside containers by providing an additional layer of abstraction and automation of OS-level virtualization on Linux."

image

  • Does exactly what we need, and it assists in efficient containerization.
  • Free and Open Source! (now under Moby)
  • Helps in packaing source code, libraries, dependencies, volumes, routes, etc for production.
  • The name Docker had roots from the word "Dock Worker", assists in effective container management.
  • Containers are built from images and saved as images.
  • Each image is identified by a UUID/256 Bit Hash.
  • Each Docker Image has several tags, and we can help in effective versioning.
  • Dockers can be secured by SSH, and additional network security techniques.

image

image

Dockerfile:

  • Dictates the program installation, setup, packaging, instructions, port exposition, etc.
  • We can run a container, list a container, version them, delete them, etc.

Sample Docker Image (for getting started):

docker run -d -p 80:80 docker/getting-started

Tools:

  • Docker Compose: It us used for maintaining and running multi-container Docker applications. We use YAML (mark-up) to dictate the format, dependencies and other nuances of a project. It can aid in building and scaling containers.
  • Docker Volume: We can store and manage separate volumes of code, that avoid deletion when the container is stopped.

Glossary:

  • Docker Daemon: The background service running on the host that manages building, running and distributing Docker containers. The daemon is the process that runs in the operating system which clients talk to.
  • Docker Client: The command line tool that allows the user to interact with the daemon. More generally, there can be other forms of clients too - such as Kitematic which provide a GUI to the users.
  • Docker Hub: A registry of Docker images. You can think of the registry as a directory of all available Docker images. If required, one can host their own Docker registries and can use them for pulling images.
  • Docker Container Image: When running a container, it uses an isolated filesystem. This custom filesystem is provided by a container image. Since the image contains the container's filesystem, it must contain everything needed to run an application - all dependencies, configuration, scripts, binaries, and so on. The image also contains other configuration for the container, such as environment variables, a default command to run, and other metadata.

Folder instructions:

  • Tutorial 1: Demonstrates a basic Docker program.
  • Tutorial 2: Demonstrates simple Redis counter example with compose.
  • Tutorial 3: Docker + NGINX Reverse Proxy + Vanilla MongoDB/NoSQL.
  • Tutorial 4: Same as Tutorial 1, but updated WSGI (Web Server Gateway Interface), instead of a default Flask development WSGI.

References:

  1. https://runnable.com/docker/python/docker-compose-with-flask-apps
  2. https://github.com/docker/awesome-compose
  3. https://docs.docker.com/language/python/build-images/
  4. https://www.cse.wustl.edu/~jain/cse570-18/ftp/m_21cdk.pdf
  5. https://en.wikipedia.org/wiki/Docker_(software)
  6. https://docs.docker.com/compose/
  7. https://docker-curriculum.com/
You might also like...
Hackergame nc 类题目的 Docker 容器资源限制、动态 flag、网页终端

Hackergame nc 类题目的 Docker 容器资源限制、动态 flag、网页终端 快速入门 配置证书 证书用于验证用户 Token。请确保这里的证书文件(cert.pem)与 Hackergame 平台 配置的证书相同,这样 Hackergame 平台为每个用户生成的 Token 才可以通

docker-compose工程部署时的辅助脚本

okta-cmd Introduction docker-compose 辅助脚本

🐳 Docker templates for various languages.
🐳 Docker templates for various languages.

Docker Deployment Templates One Stop repository for Docker Compose and Docker Templates for Deployment. Features Python (FastAPI, Flask) Screenshots D

Lima is an alternative to using Docker Desktop on your Mac.
Lima is an alternative to using Docker Desktop on your Mac.

lima-xbar-plugin Table of Contents Description Installation Dependencies Lima is an alternative to using Docker Desktop on your Mac. Description This

Build Netbox as a Docker container

netbox-docker The Github repository houses the components needed to build Netbox as a Docker container. Images are built using this code and are relea

Some automation scripts to setup a deployable development database server (with docker).

Postgres-Docker Database Initializer This is a simple automation script that will create a Docker Postgres database with a custom username, password,

A job launching library for docker, EC2, GCP, etc.

doodad A library for packaging dependencies and launching scripts (with a focus on python) on different platforms using Docker. Currently supported pl

Hatch plugin for Docker containers

hatch-containers CI/CD Package Meta This provides a plugin for Hatch that allows

Create pinned requirements.txt inside a Docker image using pip-tools
Create pinned requirements.txt inside a Docker image using pip-tools

Pin your Python dependencies! pin-requirements.py is a script that lets you pin your Python dependencies inside a Docker container. Pinning your depen

Owner
Arka Mukherjee
Master's Student in ML and CS @ Mila, University of Montreal
Arka Mukherjee
Build and Push docker image in Python (luigi + docker-py)

Docker build images workflow in Python Since docker hub stopped building images for free accounts, I've been looking for another way to do it. I could

Fabien D. 2 Dec 15, 2022
This repository contains useful docker-swarm-tools.

docker-swarm-tools This repository contains useful docker-swarm-tools. swarm-guardian This Docker image is intended to be used in a multihost docker e

NeuroForge GmbH & Co. KG 4 Jan 12, 2022
A Python library for the Docker Engine API

Docker SDK for Python A Python library for the Docker Engine API. It lets you do anything the docker command does, but from within Python apps – run c

Docker 6.1k Dec 31, 2022
Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Arie Bregman 35.1k Jan 2, 2023
Push Container Image To Docker Registry In Python

push-container-image-to-docker-registry 概要 push-container-image-to-docker-registry は、エッジコンピューティング環境において、特定のエッジ端末上の Private Docker Registry に特定のコンテナイメー

Latona, Inc. 3 Nov 4, 2021
Bitnami Docker Image for Python using snapshots for the system packages repositories

Python Snapshot packaged by Bitnami What is Python Snapshot? Python is a programming language that lets you work quickly and integrate systems more ef

Bitnami 1 Jan 13, 2022
DAMPP (gui) is a Python based program to run simple webservers using MySQL, Php, Apache and PhpMyAdmin inside of Docker containers.

DAMPP (gui) is a Python based program to run simple webservers using MySQL, Php, Apache and PhpMyAdmin inside of Docker containers.

Sehan Weerasekara 1 Feb 19, 2022
Visual disk-usage analyser for docker images

whaler What? A command-line tool for visually investigating the disk usage of docker images Why? Large images are slow to move and expensive to store.

Treebeard Technologies 194 Sep 1, 2022
Define and run multi-container applications with Docker

Docker Compose Docker Compose is a tool for running multi-container applications on Docker defined using the Compose file format. A Compose file is us

Docker 28.2k Jan 8, 2023
Docker Container wallstreetbets-sentiment-analysis

Docker Container wallstreetbets-sentiment-analysis A docker container using restful endpoints exposed on port 5000 "/analyze" to gather sentiment anal

null 145 Nov 22, 2022