I
I
Ilya2018-10-22 19:52:43
linux
Ilya, 2018-10-22 19:52:43

How to make default docker-compose variable?

In general, I didn’t find anything particularly how to make ${web:-$TAG} so that if there is no web variable, then it would then be equal to the TAG variable , TAG does not perceive it as a variable, but simply as text.
docker-compose.yml

version: '3.4'
x-variables: &config
  version: ${TAG}
services:
  postgres:
    image: postgres:${web:-$TAG}
    restart: always
    environment:
      <<: *config
    volumes:
      - "fastgate_db:/var/lib/postgresql/data"
    ports:
      - "5432:5432"

.env
TAG=6.1.0
web=DEVELOP

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
qq1, 2018-10-26
@nuBacuk

This is currently not supported, but they are working on it, you can subscribe for updates here:
https://github.com/docker/compose/issues/4836
https://github.com/docker/compose/pull/5268

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question