Dockerfile VOLUME instruction leads to incorrect image metadata
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 10.3k
- Forks
- 1.5k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 48
Description
Hello, if the VOLUME instruction is an array of single quotes or non quoted paths paths it leads to incorrect image metadata and later i cant mount a volume in the resultant path.
To reproduce i did a Dockerfile:
FROM docker.io/alpine:3.18.3
VOLUME /path1 /path2
VOLUME [/path3,/path4]
VOLUME ["/path5","/path6"]
VOLUME ['/path7','/path8']
the 2nd and 4rd VOLUME instructions didnt work as expected
commands:
docker build -t test .
docker run --rm -ti test sh
/ # tree /[
/[
├── path3,
│ └── path4]
└── path7,
└── path8]
docker image inspect test
...
"Volumes": {
"/path1": {},
"/path2": {},
"/path5": {},
"/path6": {},
"[/path3,/path4]": {},
"[/path7,/path8]": {}
},
...
the two latest i think are errors because the volumes should start with ###'/'
Expected behavior
i think the behaviour should be an error during the build, i know the array should be a valid JSON array so should only work with double quotes.
docker version
Client: Docker Engine - Community
Version: 24.0.5
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 reproducing the issue with the provided Dockerfile, docker build, docker run, and docker image inspect commands. Trace how BuildKit parses and validates the VOLUME instruction, then verify that single-quoted or malformed array syntax causes a build error instead of creating incorrect volume metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100