docker / docker/buildx

Dockerfile COPY []-Syntax no comma-validation for 2 arguments

Open
#1,328 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID:

Problem: When building an image with the current version of Docker for Windows (4.7.1 (77678)) using docker builder, We've encountered the following problem:

COPY ["testfile" "/folder/"] --> no build errors, no file in image
COPY ["testfile","testfile2" "/folder/"] --> no build errors, no file in image
COPY [ "testfile" "/folder/"] --> build fails (expected)
COPY [ "testfile","/folder/"] --> no build errors (expected)

Actual behavior

No errors while building
=> [2/2] COPY [testfile /folder/] => exporting to image => => exporting layers => => writing image sha256:3bfe5e2887105bf2f967b21ebcf5f5f28bf3b30e2e94059f8f554acc7b70ae28
docker container run testimage:latest ls -l /folder
=> ls: cannot access '/folder': No such file or directory

Expected behavior

Build fails with an error message, because there is no comma in the COPY statement.
The expected and actual behavior is equal when running in linux.

Information
  • Windows Version: 10 Pro 20H2
  • Docker Desktop Version: 4.7.1 (77678)
  • WSL2 or Hyper-V backend? WSL2
  • Are you running inside a virtualized Windows e.g. on a cloud server or a VM: No

This bug doesn't occur without buildkit.

Output of & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check
Steps to reproduce the behavior

touch testfile
echo -e 'FROM ubuntu:20.04\nCOPY ["testfile" "/folder/"]' > Dockerfile
docker image build -t testimage:latest .

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior with the Dockerfile and commands in the issue, using the COPY ["testfile" "/folder/"] form and BuildKit. Trace the Dockerfile COPY parsing and validation path, then add coverage for missing commas between two arguments. Done means malformed two-argument COPY syntax fails with an error while valid comma-separated syntax continues to build.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, dockerfile
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.