Skip to content

Docker pass secrets don't work with docker compose build #584

Description

@jamesgecko

The documentation states the following:

Anywhere Docker accepts an environment-variable value, write se://<id|pattern> and the engine resolves it just before the container starts.

This does not appear to apply to docker compose build. Here's a minimal project demonstrating the issue:

Dockerfile:

FROM alpine:latest AS base

WORKDIR /test

RUN --mount=type=secret,id=test_auth,env=TEST_AUTH \
  echo $TEST_AUTH > result.txt

CMD ["cat", "/test/result.txt"]

docker-compose.yml

services:
  app:
    build:
      context: .
      dockerfile: ./Dockerfile
      secrets:
        - test_auth

secrets:
  test_auth:
    environment: se://TEST_AUTH

Reproduction:

docker pass plugins enable 1password-cli
docker pass set TEST_AUTH="Hello world!"
docker compose build
docker compose run --rm app

Expected output: Hello world!
Actual output: Nothing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions