Skip to content

[BUG] Inconsistent compose publish behavior with variables #13394

@apollo13

Description

@apollo13

Description

It is not exactly clear from the docs how compose publish is supposed to handle variables. There is an --with-env flag which somehow seems to suggest that env variables are included in the OCI manifest. When using it docker compose asks whether sensitive variables are included, but the final manifest doesn't seem to include them anyways?

Steps To Reproduce

Using this compose file:

services:
  test1:
    image: nginx:latest
    command: ["${SECRET}"]
    environment:
      TEST: "${SECRET}"

and publishing it via:

SECRET=test docker compose publish localhost:5000/test:latest --insecure-registry

results in an error:

service "test1" has environment variable(s) declared.
To avoid leaking sensitive data, you must either explicitly allow the sending of environment variables by using the --with-env flag,
or remove sensitive data from your Compose configuration

So far so good, but publishing with --with-env doesn't really seem to result in leakage either:

SECRET=test docker compose publish localhost:5000/test:latest --insecure-registry --with-env                                                                                                                                                                                                                                                              1 ✘  14:40:46  
? you are about to publish environment variables within your OCI artifact.
please double check that you are not leaking sensitive data
Service/Config  test1
TEST=test
Are you ok to publish these environment variables? Yes
[+] push 1/1
 ✔ test1 Skipped                                                                                                                                                                                                                                                                                                                                                                       0.0s 
[+]  2/2t:5000/test:latest publishing 

When checking the published data:

regctl --host reg=localhost:5000,tls=disabled blob get localhost:5000/test:latest sha256:5868bab8f786242ba43d6604ea68ac5f4509457d6e8bfb3222ee7e85b4b9575f

it does not include the env variables:

services:
  test1:
    image: nginx:latest
    command: ["${SECRET}"]
    environment:
      TEST: "${SECRET}"

The result seems plausible to me, one usually does not want to publish with environment variables interpolated to allow for customization, but what is --with-env warning about then?

Compose Version

Docker Compose version v5.0.0-rc.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions