Is there a way to --strip-components with ADD
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 10.3k
- Forks
- 1.5k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 50
Description
A server is hosting a rootfs-wrapper.tar.xz file which instead of having this structure:
/bin
/sbin
/usr
...
is having a wrapper directory
/wrapper/bin
/wrapper/sbin
/wraper/usr
...
With regular shell we can do:
curl -O http://site/rootfs-wrapper.tar.xz
tar -xf rootfs.tar.xz --strip-components=1 -C .
How do we do that with scratch docker where we don't have access to tar and curl and viable option is to use ADD command
FROM scratch
ADD http://site/rootfs-wrapper.tar.xz /
CMD ["/bin/sh"]
it builds fine with docker build -t simple-build ., but fails to run docker run -it simple-build gives:
Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown.
If we use rootfs.tar.xz without wrapper/ then docker run works without modifying the docker.
I tried setting CMD ["/wrapper/bin/sh"] in docker as well but same result.
Is there a way to make ADD command strip components of tar?
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 Dockerfile example using ADD with rootfs-wrapper.tar.xz and the scratch base, then compare it with the archive that has no wrapper directory. Done means determining whether ADD can remove the leading archive component and confirming that the resulting image can start /bin/sh.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, dockerfile
- Domain
- build-system, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100