docker-compose.yml is a YAML-format configuration file. It lets you write out the services, images, ports, volumes, and environment variables your app needs in a readable way.
dockerfile
# Create a file named docker-compose.yml
services:
web:
image: nginx:alpine
ports:
- "8080:80"
redis:
image: redis:alpine
volumes:
- redis-data:/data
volumes:
redis-data:web service runs Nginx and maps it to host port 8080. The redis service runs a Redis cache and stores its data in the redis-data volume.
You should see
This file defines a stack with two services: a web server and Redis.Info
Docker creates a Compose network by default, so services can reach each other by service name. For example, from inside the web app, you can connect to Redis at redis:6379.