Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env vars alternative substitution interpolation #6918

Closed
wants to merge 1 commit into from

Conversation

zorn-v
Copy link

@zorn-v zorn-v commented Sep 25, 2019

... VAR is set and not null VAR is set and null VAR is unset
${VAR:+word} substitute word substitute null substitute null
${VAR+word} substitute word substitute word substitute null

Maybe it not so much use cases for this but may be useful.

Consider nginx image with following config with ato redirect http to https if connect on 80 port

    listen 80;
    listen 443 ssl http2;
    listen 8000;
...
    if ($server_port = 80) {
         return 301 https://$host$request_uri;
    }

On some containers you do not need that redirect, but don't want to use something like HTTP_CONTAINER_PORT=8000 but NO_HTTPS_REDIRECT=1
Then you can use following port mapping

ports:
  - 80:80${NO_HTTPS_REDIRECT+00}

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "interpolation-alt" git@github.com:zorn-v/compose.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

Signed-off-by: zorn <zorn7@yandex.ru>
@ndeloof
Copy link
Contributor

ndeloof commented Nov 19, 2019

Sounds to me this is a reasonable feature, I'm a bit concerned there's not realistic use-case driving it, and this will introduce more complexity to newcomers who might not be confident with bash-style parameter interpolation.

Also will need to be implemented in a consistent way in https://github.com/docker/cli/tree/master/cli/compose/interpolation

@glours
Copy link
Contributor

glours commented Jul 13, 2022

Thanks for taking the time to create this issue/pull request!

Unfortunately, Docker Compose V1 has reached end-of-life and we are not accepting any more changes (except for security issues). Please try and reproduce your issue with Compose V2 or rewrite your pull request to be based on the v2 branch and create a new issue or PR with the relevant Compose V2 information.

@glours glours closed this Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants