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

Docker cp fails when the container is running with volume mount and read only root filesystem #43015

Open
orzlc opened this issue Nov 14, 2021 · 2 comments
Labels
area/api area/volumes kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. version/20.10

Comments

@orzlc
Copy link

orzlc commented Nov 14, 2021

Docker version 20.10.10 API 1.41

Docker cp command fails when container runs with --read-only flag, parent folder is a symlink and the inner folder is mapped from a volume.

Reproduce steps:

  1. Create a dockerfile with a symlink in parent path, for example:
FROM ubuntu:latest
RUN ln -s /tmp /dir1
  1. Run a container of the image with the following flags:
docker run -it --read-only -v /dir1/dir2 IMAGE
  1. Copy a file to the volume:
docker cp FILE CONTAINER:/dir1/dir2
Error response from daemon: container rootfs is marked read-only

Should be able to copy the files using docker cp command.
There are no issues with creating files in this directory when running from within the container, only copying from host fails.

@kyrofa
Copy link

kyrofa commented May 14, 2022

Just ran into this myself, still an issue.

@corhere corhere added area/api kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. area/volumes version/20.10 labels Jul 5, 2022
@thaJeztah
Copy link
Member

Discussing in the maintainers meeting; there was some discussion wether or not the symlink should be followed or not (as it should also be possible to copy a symlink into the container and vice-versa). In this case, it's not the last path element that is the symlink, so following the symlink makes sense (and should not be ambiguous).

Let me link to the related code path, in case someone is interested in working on this issue;

moby/daemon/archive.go

Lines 353 to 363 in 7b9275c

// @ TODO: gupta-ak: Technically, this works since it no-ops
// on Windows and the file system is local anyway on linux.
// But eventually, it should be made driver aware.
toVolume, err := checkIfPathIsInAVolume(container, absPath)
if err != nil {
return err
}
if !toVolume && container.HostConfig.ReadonlyRootfs {
return ErrRootFSReadOnly
}

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

No branches or pull requests

4 participants