When setting up self-hosted services, testing open-source projects, or copying quick commands from GitHub READMEs, documentation almost always gives you a docker run one-liner:
docker run -d \ --name postgres_db \ -p 5432:5432 \ -v pgdata:/var/lib/postgresql/data \ -e POSTGRES_PASSWORD = supersecret \ -e POSTGRES_USER = admin \ --restart unless-stopped \ postgres:16-alpine
Enter fullscreen mode
Exit fullscreen mode
While great for testing, running containers via individual commands is difficult to maintain in production. You forget which flags you passed, configurations aren't tracked in version control, and restarting a machine requires hunting through your bash history.
The standard fix is writing a docker-compose.yml file.β¦