Menu

Docker Run to Docker Compose: Stop Converting Commands by Hand
πŸ“°

Docker Run to Docker Compose: Stop Converting Commands by Hand

DEV Community: dockerΒ·Rashid SalimovΒ·about 18 hours ago
#qRP8oN4k
#devtodocker#devto#dev#docker#compose
Reading 0:00
15s threshold

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.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.