Multiple Image Tags with Docker Compose
Contents
Recently I answered a question on Stack Overflow
How to use multiple image tags with docker-compose?
The validated answer was based on extends
, but it cannot by used anymore in Compose file format 3.x
. As suggested by a user, the Extension fields capability added in the version 3.4
of Docker Compose can replace it to achieve the same goal: reuse a single definition to set several tags.
Use YAML extension to define multiple tags
Here is how to use YAML
extensions in this case.
|
It uses an .env
file to define environment variables.
|
Build images
Images can be built now with all the defined tags.
|
Images could also be pushed in the same way.