-
Notifications
You must be signed in to change notification settings - Fork 0
5. Docker in Production ✨
Aditya edited this page Jan 15, 2021
·
1 revision
- Docker in Production
Table of contents generated with markdown-toc
- Many initial container project are too big in scope
- Solutions you maybe don't need on Day 1:
- Fully automatic CI/CD
- Dynamic performance scaling
- Containerizing all or nothing
- Starting with persistent data
- Microservice conversion isn't required.
- 12 Factor is a horizon we're always chasing.
- Don't let these ideals delay containerization.
- More important than fancy orchestration; it's your new build and environment documentation.
- Study Dockerfile/ENTRYPOINT of Hub Officials
- Make it start
- Make it log all thing to stdout/stderr
- Make it documented in file
- Make it work for others
- Make it lean
- Make it scale
-
Problem: Storing unique data in container
-
Solution: Define
VOLUMEfor each locationVOLUME /var/lib/mysql ENTRYPOINT ["docker-entrypoint.sh"] CMD ["mysqld"]
-
Latest = Image builds will be o((⊙﹏⊙))o.
-
Problem: Image builds pull FROM latest
-
Solution: Using specific FROM tags
-
Problem: Image builds install latest packages
-
Solution: Specify version for critical
apt/yum/apkpackages.FROM php:7.0.24-fpm ENV NGINX_VERSION 1.12.1-1~jessie\ NODE_VERSION 6.11.4
FROM ubuntu:xenial-20170915 RUN apt-get update && apt-get install g++
- Problem: Not changing app defaults, or blindly copying VM conf.
- E.g., php.ini, mysql.conf.d, java memory.
- Solution: Update default configs via
ENV,RUNandENTRYPOINT.
-
Problem: Copy in environment config at image build
-
Solution: Single Dockerfile with default
ENV's, and overwrite per-environment withENTRYPOINTscript.FROM node:6.10 COPY test-environment.json test-environment.json
-
Containers-on-VM or Container-on-Bare-Metal ?
- Do either, or both. Lots of pros/cons to either
- Stick with what you know at first
- Do some basic performance testing.
-
OS Linux Distribution/Kernel Matters ?
- Docker is very kernel and storage driver dependent
- Innovations/fixes are still happening here.
- "Minimum" version != "best" version
- No pre-existing opinion ? Ubuntu 16.04 LTS
- Popular, well-tested with Docker
- 4.x Kernel and wide storage driver support
- Or Infrakit and LinuxKit
-
Container base Distribution: Which One ?
- Which FROM image should you use ?
- Don't make a decision based on image size (remember it's Single Instance Storage)
- At first, match your existing deployment process
- Consider changing to
Alpinelater, maybe much later.