Skip to content

Environment should not be set in build context #985

@emersion

Description

@emersion

Describe the bug
Values in environment in docker-compose.yaml should not be set during container build, they should only be set during runtime.

To Reproduce

Dockerfile:

FROM alpine:latest
RUN ["env"]

docker-compose.yaml:

services:
  test:
    build:
      context: .
    command: ["env"]
    environment:
      FOO: bar

Expected behavior
FOO is not set when running podman-compose build, FOO is set when running podman-compose up.

Actual behavior
FOO is set in both cases.

Output

$ podman-compose version
podman-compose version 1.1.0
podman version 5.1.1

$ podman-compose build
STEP 1/3: FROM alpine:latest
STEP 2/3: ENV "FOO"="bar"
--> fe6bfa40f69f
STEP 3/3: RUN ["env"]
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
HOSTNAME=722db47f04e9
HOME=/root
COMMIT test_test
--> 4feeb8478ac8
Successfully tagged localhost/test_test:latest
4feeb8478ac84701a1757400eac398fc27391bebb691e09a60958b602a742d6b

$ podman-compose up
fb31413e53aad1ce59ab3f3d978041372023d1d249e40af2dc9ac0efef5b7495
0a4e21b7976abc4d8dd6b5570021e8a0f843d5225363a79030a74e61ee90255a
[test] | container=podman
[test] | FOO=bar
[test] | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[test] | HOME=/root
[test] | HOSTNAME=0a4e21b7976a

Environment:

  • OS: Linux
  • podman version: 5.1.1
  • podman compose version: 1.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions