Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle relative paths in VOLUME directives #46093

Open
cpuguy83 opened this issue Jul 27, 2023 · 1 comment
Open

Handle relative paths in VOLUME directives #46093

cpuguy83 opened this issue Jul 27, 2023 · 1 comment
Labels
area/runtime kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.

Comments

@cpuguy83
Copy link
Member

cpuguy83 commented Jul 27, 2023

Description

In runc 1.0, runc started erroring out if a mount destination was a relative path.
This was changed to be just a warning here: opencontainers/runc#3004
An issue was created to re-add the error: opencontainers/runc#3020
As part of id-mapped mounts support, this was added back here: opencontainers/runc#3717

We need to handle this case because we don't want to break old images or builds.

Reproduce

N/A

Expected behavior

N/A

docker version

N/A

docker info

N/A

Additional Info

No response

@cpuguy83 cpuguy83 added status/0-triage kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. area/runtime and removed status/0-triage labels Jul 27, 2023
@thaJeztah thaJeztah changed the title Handle relatative paths in VOLUME directives Handle relative paths in VOLUME directives Jul 27, 2023
@thaJeztah
Copy link
Member

So for docker run at least it looks like we're producing an error;

docker run -it --rm --workdir=/hello -v foovolume:world alpine
docker: Error response from daemon: invalid volume specification: 'foovolume:world': invalid mount config for type "volume": invalid mount path: 'world' mount path must be absolute.
docker run -it --rm --workdir=/hello -v foovolume:./world alpine
docker: Error response from daemon: invalid volume specification: 'foovolume:./world': invalid mount config for type "volume": invalid mount path: './world' mount path must be absolute.

For docker build with BuildKit, it looks like we're silently allowing the relative path;

docker build -t foo -<<'EOF'
FROM alpine
WORKDIR /hello
VOLUME ./world
VOLUME world2
EOF

So the image's config has the relative path:

docker image inspect --format '{{ json .Config.Volumes}}' foo
{"./world":{},"world2":{}}

Which gets fixed "somewhere" when running a container from it.

docker run --rm foo sh -c 'mount | grep world'
/dev/vda1 on /world2 type ext4 (rw,relatime,data=ordered)
/dev/vda1 on /world type ext4 (rw,relatime,data=ordered)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
Projects
None yet
Development

No branches or pull requests

2 participants