postgres_binaries.txt (4723B)
1 =============================================================================== 2 POSTGRES BINARIES 3 =============================================================================== 4 5 ------------------------------------------------------------------------------- 6 1. POSTGRES BINARIES & FILE STRUCTURE 7 ------------------------------------------------------------------------------- 8 9 +------------------------------------------------------------------+ 10 | Docker Container | 11 | +------------------------------------------------------------+ | 12 | | OS | | 13 | | | | 14 | | /usr/lib/postgresql/ | | 15 | | | | 16 | | +-----------------------------------------------------+ | | 17 | | | data | | | 18 | | | ------------------> /var/lib/postgresql/data | | | 19 | | +-----------------------------------------------------+ | | 20 | | | | 21 | | +-----------------------------------------------------+ | | 22 | | | lib | | | 23 | | | ------------------> *.so shared libraries | | | 24 | | +-----------------------------------------------------+ | | 25 | | | | 26 | | +-----------------------------------------------------+ | | 27 | | | bin --> Postgres executables: | | | 28 | | | postgres (server daemon) | | | 29 | | | psql (CLI, libpq) | | | 30 | | | initdb (init data dir) | | | 31 | | | pg_ctl (server control) | | | 32 | | | createdb / dropdb | | | 33 | | | createuser / dropuser | | | 34 | | | pg_dump, pg_dumpall, pg_restore | | | 35 | | | (backup/restore utilities) | | | 36 | | | ... | | | 37 | | +-----------------------------------------------------+ | | 38 | +------------------------------------------------------------+ | 39 +------------------------------------------------------------------+ 40 41 42 ------------------------------------------------------------------------------- 43 2. SERVICE VS. SUPPORTING TOOLS 44 ------------------------------------------------------------------------------- 45 46 +--------------+ 47 | postgres | <-- one service, PID 1 48 | (the thing | (what the container is about) 49 | container is | 50 | all about) | 51 +------+-------+ 52 +---------+--------+---------+---------+ 53 | | | | | 54 +----+----+ +--+-----+ +--+-----+ +--+-----+ 55 | psql | | pg_dump| |pg_upgrade| |vacuumdb| 56 +---------+ +--------+ +----------+ +--------+ 57 58 many binaries - supporting tools 59 60 Traditional Unix packaging carried into containers. 61 62 63 ------------------------------------------------------------------------------- 64 3. COMPARATIVE PHILOSOPHY 65 ------------------------------------------------------------------------------- 66 67 Typical Docker: "one binary per container" 68 - small image, minimal attack surface 69 - "this container runs exactly this one app" 70 - you lose built-in tools, need lots of sidecars 71 72 Postgres Docker: 73 - "single concern" != "literally one executable on disk" 74 - you can, and often should, ship a toolbox with the main service 75 76 77 ------------------------------------------------------------------------------- 78 4. EXAMPLE RUST APP 79 ------------------------------------------------------------------------------- 80 81 +------------------------------------------------------------------+ 82 | Docker Container | 83 | | 84 | main binary --> Running as PID 1 +--------------+ | 85 | ops binary | CLI TOOL | | 86 | | debug binary| | 87 | | +--------------+ | 88 | | pipe | 89 | +-------------------------------> maintenance binaries | 90 +------------------------------------------------------------------+