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

Environment variables defined in compose file are included in image build #931

Open
uosis opened this issue May 7, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@uosis
Copy link

uosis commented May 7, 2024

Describe the bug

Environment variables defined in compose file are included in image build. They should only be defined at runtime.

Aside from being a deviation from docker compose behavior, this is a potential security concern since it is common for those variables to contain secrets.

To Reproduce
Dockerfile:

FROM scratch

compose.yaml:

version: "3"
services:
  foo:
    image: foo:latest
    build: .
    environment:
      FOO: bar

podman compose build foo:

STEP 1/2: FROM scratch
STEP 2/2: ENV "FOO"="bar" # note this variable that should not be part of build
COMMIT foo:latest
--> 9f279e6856c7
Successfully tagged localhost/foo:latest

podman image inspect foo:latest|jq '.[0].Config.Env':

[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "FOO=bar" # note this variable that should not be part of build
]

docker compose behaves correctly:

docker compose build foo
docker image inspect foo:latest|jq '.[0].Config.Env'
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  # note the absence of FOO variable
]

Expected behavior
Environment variables defined in compose file should not be included in build.

Actual behavior
Environment variables defined in compose file are included in build.

Output

$ podman-compose version
podman-compose version 1.1.0
podman version 5.0.2

Environment:

  • OS: Linux
@uosis uosis added the bug Something isn't working label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant