What is Docker Compose?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Docker basics — a prerequisite for any developer role.
Answer
Docker Compose is a tool for defining and running multi-container Docker applications using a YAML configuration file (docker-compose.yml or compose.yml). Instead of running long docker run commands for each service, Compose lets you define all services, their configurations, networks, and volumes in one file, then start everything with a single command. Basic docker-compose.yml: version: "3.9"\nservices:\n web:\n build: .\n ports:\n - "3000:3000"\n environment:\n - NODE_ENV=development\n volumes:\n - .:/app\n depends_on:\n - db\n db:\n image: mysql:8.0\n volumes:\n - dbdata:/var/lib/mysql\n environment:\n MYSQL_ROOT_PASSWORD: secret\nvolumes:\n dbdata:. Key commands: docker compose up -d — start all services in background; docker compose down — stop and remove containers; docker compose logs -f web — follow logs; docker compose exec web bash — open shell in running service; docker compose build — rebuild images; docker compose ps — list service status. Services on the same Compose network can reach each other by service name (db, web).
Common Mistake
A common mistake is memorizing definitions without understanding implications. When asked this question, go one level deeper — explain what happens when this concept is misused or ignored.