GithubHelp home page GithubHelp logo

rasla / docker-magic Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 1.0 1.06 MB

Course materials about Docker, Docker-Compose and Kubernetes

License: MIT License

Shell 30.93% Dockerfile 9.51% Python 11.59% PHP 11.71% HTML 3.49% Makefile 17.66% Java 5.07% Go 2.76% Smarty 7.28%

docker-magic's Introduction

Docker Magic

This repo contains Docker's usage examples.

I divide Docker-Magic into 3 levels:

  1. Docker - using the single docker container, including topics:
    • Get docker-image;
    • Make docker-image (with Dockerfile);
    • Run docker-container;
    • Run docker-container with custom params (env-vars, port-mapping, disk-volumes, as specific user);
  2. Docker-compose - using the application from several Docker-containers (on a single server), including topics:
    • Combine few docker-images into the Application
    • Configure Application (for multi envs/users)
    • Mapping files/dirs between docker-containers and Host-OS
    • Mapping TCP/UDP ports between docker-containers and Host-OS
    • Limits of the resources for docker-containers
  3. Kubernetes - using the orchestrator for full control (many applications, multi-server cluster):
    • Deploy Pods (containers) in Kubernetes-cluster
    • Configure Applications by ConfigMaps, ENV-vars and Secrets
    • Expose HTTP / HTTPS routes and TCP ports for the services
    • Persistent Storage for some Pods

Requirements

  • Install Docker-CE
    or deb-package docker.io (Ubuntu 16.04+, Debian 10+): sudo apt install docker.io

  • (optional, but recommended) Post-installation steps for Linux:

    • Manage Docker as a non-root user
    • Configure Docker to start on boot
    • Create user-defined network: docker network create app
  • To install Docker-Compose make a few steps (on Linux):

    sudo apt install python3-pip;
    sudo pip3 install docker-compose==1.27.4

YAML-linter

IMPORTANT Before commit changes - you MUST check code (& fix errors, if possible) by linter:

## (once) Install Linters
sudo pip3 install yamllint==1.28.0

## PRE-commit check
yamllint .

Production and Development advices

  • Use Alpine Linux docker-images as base, if it possible (postgres:12-alpine instead of postgres:12, for example)
  • Update your docker-images ASAP, when the base-image is updated
  • Use .dockerignore file - prevent unnecessary files from appearing in the docker-image

Development environment

  1. The developer's docker-image may exclude the source code for interpreted languages (like PHP, Python etc), if it is sufficient to build the Runtime docker-image and mount the Sources as a Volume to the docker-container.

  2. Developer's docker-images may contain some useful tools, such as XDebug (for PHP), etc. that are not needed in the production docker-images.

Production environment

  1. The Production docker-image MUST contain all Application files inside docker-image !
    The only exception is - connecting to the production docker-container external persistent storage for the Logs and Data (like: MySQL data-dir, shared assets-folder for Samba/NFS, etc).

  2. The Production docker-image MUST NOT contain any unnecessary tools and files !

    • Less files - less docker-image size;
    • Less binary - less potential vulnerabilities

docker-magic's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

egor18032019

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.