Dockerfile: warn when trying to COPY/ADD using "~"
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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