WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Wich Dockerfile version does WSLc support?

Open ConPac opened this issue 3 months ago • 6 comments

Hi,

I've just started with WSLc (from WSL 2.9.4.0) using a Dockerfile with a "COPY --exclude" instruction, which needs at least Dockerfile version 1.19 (as per https://docs.docker.com/reference/dockerfile/#copy)

So, which Dockerfile version does WSLc support? Or, where are its supported instructions documented?

Thanks in advance.

ConPac avatar Aug 05 '26 12:08 ConPac

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

Once completed please upload the output files to this GitHub issue.

See Collect WSL logs (recommended method).

If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

github-actions[bot] avatar Aug 05 '26 12:08 github-actions[bot]

/question

ConPac avatar Aug 05 '26 12:08 ConPac

Diagnostic information
Found '/question', adding tag 'question'

github-actions[bot] avatar Aug 05 '26 12:08 github-actions[bot]

WSLc does not appear to document its own separate “Dockerfile version” such as 1.19. WSLc uses its container build implementation, and Microsoft’s current WSL container documentation demonstrates building with a normal Containerfile/Dockerfile syntax.

The confusing part is that Docker’s COPY --exclude requirement is specifically tied to Dockerfile syntax version 1.19:

syntax=docker/dockerfile:1.19

FROM ... COPY --exclude=*.txt . /app/

Docker’s documentation explicitly lists:

COPY option

Minimum Dockerfile version

--chmod

1.2

--link

1.4

--parents

1.20

--exclude

1.19

And here’s the interesting bit about WSLc

WSLc was only introduced as a public preview in WSL 2.9.3, so WSL 2.9.4 is extremely new territory. Microsoft’s release notes describe wslc build and the container functionality, but they do not publish a table mapping WSLc to Dockerfile syntax versions.

Microsoft’s own current tutorial uses:

Containerfile

and builds it with: PowerShell wslc build -t helloworld-django .

rather than specifying a Dockerfile frontend version.

So if you’re trying to determine whether this works:

Dockerfile COPY --exclude=...

the safest answer is: don’t assume that WSLc 2.9.4 supports Dockerfile syntax 1.19 merely because Docker does.

Dockerfile syntax version ≠ WSL version ≠ BuildKit version.

WSLc is its own container implementation.

If you’re testing this on WSLc 2.9.4

I’d test it directly with a tiny Dockerfile: # syntax=docker/dockerfile:1.19

FROM alpine

COPY --exclude=*.txt . /test/

Then: PowerShell

wslc build -t test-exclude .

If WSLc doesn’t understand the directive/feature, the build output should tell us exactly what parser/builder behavior it’s using.

If you’re trying to figure out why COPY --exclude is failing on your WSLc 2.9.4 installation possibilities could be:

Dockerfile syntax limitation, BuildKit/frontend issue, or something specific to WSLc.

Dpasser avatar Aug 08 '26 19:08 Dpasser

WSLc uses a BuildKit-based build implementation, so which Dockerfile instructions work is essentially "whatever the bundled BuildKit frontend supports" — there isn't a separate "wslc Dockerfile version" number like the Dockerfile 1.x syntax versions.

For the specific COPY --exclude case: that landed in BuildKit's Dockerfile frontend around Dockerfile 1.9/2.x. Whether it works on wslc 2.9.4.0 depends on the BuildKit version shipped inside the wslc utility VM — not all newer frontend features are guaranteed present, since wslc pins its own BuildKit rather than tracking Docker's latest.

Practical test if COPY --exclude fails:

# see the build output — BuildKit frontend errors usually name the unsupported instruction
wslc build -t test:1.0 .
# workaround: pre-exclude with a .dockerignore instead
# .dockerignore
node_modules/
*.log

A .dockerignore achieves the same "don't copy these" result and is supported regardless of the Dockerfile syntax version.

(For the full list of which docker build flags and instructions wslc 2.9.4.0 supports, I keep a verified matrix at https://wslcontainers.com/commands/build/.)

ylwl1997 avatar Aug 10 '26 02:08 ylwl1997

Hi,

Thanks for your time and answers, @Dpasser and @ylwl1997. I'll stick to the old good known pattern COPY and RUN rm.

Hope a future WSLc release could support also builds with --build-context.

ConPac avatar Aug 17 '26 12:08 ConPac