podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

Build env variables not used in Dev Containers

Open tbukic opened this issue 9 months ago • 2 comments

Describe the bug When used in Dev Containers settings, build arguments for dockerfile are not passed to Podman from podman-composeto Podman.

To Reproduce Steps to reproduce the behavior:

  1. Use this repo: https://gitlab.com/cognitive-science1/fsl-starter/
  2. Open it in VS Code
  3. Open it in Dev Containers This is tested on PopOS! (Ubuntu22.04) based system with NVidia RTX 2080, driver 565.77. One can disable including GPU with deleting lines lines L27-L33 in Dockerfile.

Expected behavior Image is failing to build since it is searching for "default" version (intentionally incorrect). This means no argument is passed from docker-compose.yml to the podman's build process, and build is falling back to default arguments defined in Dockerfile.

Actual behavior Process should use arguments given in

Output

$ podman-compose version
podman-compose version 1.3.0
podman version 4.6.2
podman --version 
podman version 3.4.0

$ podman version
Client:       Podman Engine
Version:      4.6.2
API Version:  4.6.2
Go Version:   go1.18.1
Built:        Thu Jan  1 01:00:00 1970
OS/Arch:      linux/amd64

Environment:

  • OS: Linux
  • podman version: 4.6.2
  • podman compose version: (git hex) c46ecb226beedc761f850a403f23009f70fb14b5
    • podman compose installed via 'podman-compose @ git+https://github.com/containers/podman-compose.git@c46ecb226beedc761f850a403f23009f70fb14b5'

Additional context

This is tested only in devcontainer settings in settings in which docker compose works fine. VS Code Settings to reproduce this issue:

  • Dev > Containers: Docker compose Path: podman-compose
  • Dev > Containers: Docker compose Path: podman-compose
  • Dev > Containers: Docker Socket Path: unix:///run/user/1000/podman/podman.sock

tbukic avatar Mar 31 '25 13:03 tbukic

Hi @tbukic

Can you please provide a reproducer with a minimal Dockerfile and docker-compose.yml file and using the podman-compose command.

After reading your bug report I'm not exactly sure what the issue is but it seems like it could be reproduced without your complex example.

Please let me know.

ninja-quokka avatar Apr 07 '25 02:04 ninja-quokka

Hi @tbukic

Can you please provide a reproducer with a minimal Dockerfile and docker-compose.yml file and using the podman-compose command.

After reading your bug report I'm not exactly sure what the issue is but it seems like it could be reproduced without your complex example.

Please let me know.

Description: The build arguments specified in docker-compose.yml are not being properly passed to the Dockerfile during the build process. This causes conditional logic based on these arguments to fail, particularly affecting dependency installation.

Reproduction Steps:

  1. Define a build argument in docker-compose.yml:
  django:
    container_name: django
    build:
      context: "."
      dockerfile: "./Dockerfile"
      args:
        BUILD_ENV: dev
  1. Reference this argument in Dockerfile with conditional logic:
ARG BUILD_ENV=prod
RUN poetry install --no-root $(test "$BUILD_ENV" != "dev" && echo "--without dev")
  1. Build and run the container using podman-compose up -d --build

Expected Behavior:

When BUILD_ENV=dev is set in docker-compose.yml or passed wi:

  • Poetry should install all dependencies, including dev dependencies
  • The test command should evaluate to false, omitting the --without dev flag

Actual Behavior:

  • The build argument is ignored
  • Default value (prod) is always used
  • Result: Dev dependencies are not installed regardless of the compose file setting

Impact:

  • Development dependencies are missing in dev environments
  • Container can't start because of missing dependencies

Also podman-compose up -d --build-arg BUILD_ENV=dev --build doesn't seem to work either

quevon24 avatar Apr 22 '25 21:04 quevon24