I have a docker-compose.yml
which looks like
version: '2'
services:
redis:
image: redis
mysqldb:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=passme
- MYSQL_DATABASE=mydb
- MYSQL_USER=root
base:
build: .
volumes:
- .:/proj
environment:
- ENV_1=Value_1
- ENV_2=Value_2
- ENV_3=Value_3
worker:
extends:
service: base
command: celery -A proj worker --loglevel=debug
links:
- redis
- mysqldb
depends_on:
- mysqldb
web:
extends:
service: base
links:
- mysqldb
- redis
depends_on:
- mysqldb
ports:
- "8000:8000"
command: python manage.py runserver 0.0.0.0:8000
Now, I want to upgrade it to version-3.
From the doc
The
extends
keyword is supported in earlier Compose file formats up to Compose fileversion 2.1
(see extends in v1 and extends in v2), but is not supported in Composeversion 3.x
So, here is my question, How can I use Version-3 docker-compose file without losing my current functionalities?
Extending services isn't supported in version 3 after removal of
extends
.As for workaround, you can use
docker-compose addons
, e.g.Another way is to include multiple composer files from the command-line (with multiple
-f
options). See: Add support for multiple composefile when deploying. E.g.Source: When using multiple docker-compose.yml files from different directories, local paths are not followed correctly.
In general, version 3 is more ideal for Swarm/Kube stacks, so consider using it.
E.g.
Related:
extends
feature in Compose v3 / docker stack deployThe document in docs.docker.com community is so clear on what changes were made from 2.x to 3.x and what need to be done to upgrade it; I request you make use of those link to upgrade the docker-compose file. I am sharing the link for your information here and search for "Version 2.x to 3.x" and more over the document also talks about what needs to be done for the keyword extend; search for "Extending services" in the link.