Using dots in Docker Compose
Adding dots to Docker Compose files.
Docker Compose v1
Assuming you have a demo
app which has services defined in a Docker Compose v1 file:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
To dotmesh-enable the redis
, simply add these three lines at the bottom of the file:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
volume_driver: dm
volumes:
- "demo.redis:/data"
Note that this example creates a dot called demo
with a subdot called redis
.
Docker Compose v2 and v3
Define your volumes centrally under the top-level volumes
, then refer to them by name in your services.
For example, starting with a file that looks like:
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
Update it accordingly:
version: '3'
volumes:
demo.redis:
driver: dm
services:
web:
build: .
ports:
- "5000:5000"
redis:
image: "redis:alpine"
volumes:
- "demo.redis:/data"
This works in the same way for Docker Compose v2 and v3 files.