Skip to content

Build secrets from compose file are ignored if features are specified #997

@kahrpatrick

Description

@kahrpatrick

Problem

When specifying features and dockerComposeFile in devcontainer.json, build secrets specified in the referenced compose file get ignored when generating the compose override file.

Building the container will exit with:

failed to solve: unexpected key 'env' in 'env=SOME_SECRET'
Error: Command failed: docker compose --project-name ...

Steps to reproduce

  1. Create a compose file with build secrets:
---
services:
  my-service:
    image: my-image
    build:
      secrets:
        - some-secret
      ...
secrets:
  some-secret:
    file: /path/to/secret/file
...
  1. Consume secrets in Dockerfile:
...

RUN --mount=type=secret,id=some-secret,env=SOME_SECRET ...
...
  1. Create devcontainer configuration:
{
  ...
  "dockerComposeFile": "./my-compose.yml",
  "service": "my-service",
  "features": {
    "some-feature": {}
  }
  ...
}
  1. Build the container with: devcontainer build --no-cache --workspace-folder . and observe failure log.
  2. Comment the "features" option in the devcontainer config file and build with success.

Versions

devcontainer: 0.76.0
docker: 28.0.4
docker compose: 2.34.0
platform: Linux (6.6.85-2-MANJARO)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions