Docker compose
What is Docker compose?
Docker compose orchestrates an environment to run multi-container Docker applications. In layman’s language, it enables you to bring multiple containers together to make an application.
Docker compose makes use of a yaml file to define services that are later used to start and run the application with a single command.
Initially, you will have to make the respective Dockerfiles and set up the environment according to the application’s need. Then, download all the dependencies and install all the packages.
A typical docker-compose.yml file looks like this:
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
- logvolume01:/var/log
links:
- redis
redis:
image: redis
volumes:
logvolume01: {}
- There are two services running, web and
.redis an in-memory data structure store used as a database, cache, and message broker
web
buildfrom Dockerfile in the parent directory.- Mapped both internal and external
portto . - Parent directory (
.) is mapped to/code, and dictionary (logvolume01) is mapped to/var/login the container. linksto therediscontainer.
redis
- Builds redis service using the
redisimage.
After the yaml file is set up, run:
docker-compose up
This will start up the services specified in the yaml files.
Summary
- Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
- Define the services that make up your app in
docker-compose.ymlso they can be run together in an isolated environment. - Run
docker-compose upand Compose will run your entire app.
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved