Data Engineering

Docker Compose

docker-compose.yml file, services, depends_on, healthchecks, shared volumes, networks, environment variables, profiles

20 interview questionsยท
Mid-Level
1

What is the main role of a docker-compose.yml file?

Answer

The docker-compose.yml file allows defining and running multi-container Docker applications. It describes services, their images, volumes, networks, and dependencies in a declarative YAML format. This simplifies starting complex environments with a single docker compose up command.

2

Which command starts all services defined in docker-compose.yml in the background?

Answer

The docker compose up -d command starts all services in detached (daemon) mode. The -d flag allows containers to run in the background, freeing the terminal. Without this flag, logs from all services display in the terminal and stopping the process stops the containers.

3

How to define a named volume shared between multiple services in docker-compose.yml?

Answer

Named volumes are declared in a volumes: section at the root level of the file, then referenced in each service. Unlike bind mounts, named volumes are managed by Docker and persist independently of containers. They allow reliable data sharing between services.

4

What is the difference between depends_on and healthcheck in Docker Compose?

5

How to configure a healthcheck for a PostgreSQL service in docker-compose.yml?

+17 interview questions

Master Data Engineering for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free