Docker Compose build secrets are not injected in the Dockerfile

69 views Asked by At

Docker Compose has support for build time secrets since a while now. I tried using Docker Compose build secrets using the samples provided in the Docker Compose pull request but the secrets are not injected in the Dockerfile when I use docker compose build. I'm using Docker Desktop on Windows 10 (I just did a fresh install). When trying the same command using the same files in an Ubuntu VM, the secrets are injected in the Dockerfile.

What could be wrong?

docker-compose.yml

services:
  ssh:
    image: build-test-secret
    build:
      context: .
      secrets:
        - mysecret

secrets:
  mysecret:
    file: ./secret.txt

Dockerfile

FROM alpine

RUN echo "foo" > /tmp/expected
RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret > /tmp/actual
RUN diff /tmp/expected /tmp/actual

secret.txt

foo

The output of docker version on the Windows 10 machine is:

Client:
 Cloud integration: v1.0.35+desktop.5
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:32:48 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.25.0 (126437)
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:32:16 2023
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

And the output of docker compose version on the Windows 10 machine is:

Docker Compose version v2.23.0-desktop.1
0

There are 0 answers