moby / moby/buildkit

Dockerfile: warn when trying to COPY/ADD using "~"

Open
#2,176 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/dockerfile area/ux kind/enhancement
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

This is not really a bug, but this may be unexpected for users.

When using ~ as target for a COPY or ADD, the ~ is used as a literal character for the path.

For example:

touch somefile.txt
FROM alpine
COPY somefile.txt ~/somefile.txt
$ docker build -t foo .
$ docker run --rm foo sh -c 'find / -name somefile.txt'
/~/somefile.txt

Note that a literal ~ directory is created, and somefile.txt is copied into that directory.

Perhaps (once we support warnings / non-fatal errors) we can add a warning for this.

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

Start by running the Dockerfile example from the issue and confirm that COPY somefile.txt /somefile.txt creates //somefile.txt. Inspect the Dockerfile COPY/ADD handling and the project's warning support, then make the completed behavior warn about the literal ~ destination without making the build fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
dockerfile, go
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.