In my container, I have a folder that contains a relative symlink to a parent's parent subfolder:
$ docker run --name symlink-test ubuntu bash -c "mkdir -p /1/2; touch /1/2/a; ln -s ../../usr /1/2; touch /1/2/z; ls -l /1/2" :(
total 4
-rw-r--r--. 1 root root 0 Mar 4 03:37 a
lrwxrwxrwx. 1 root root 9 Mar 4 03:37 usr -> ../../usr
-rw-r--r--. 1 root root 0 Mar 4 03:37 z
I want to copy the folder /1
to the host. However, I always get the following error:
$ docker cp symlink-test:/1/2
invalid symlink "/tmp/2/usr" -> "../../usr"
$ ls 2
a
Copying the files fails and docker cp
aborts after it sees the symlink.
There are some Docker bugs related to this, but they are either fixed or were caused by something different:
- FATA[0000] invalid symlink when copying a symlink with relative parent paths
- Error attempting to cp directory containing symlink
I'm running Docker 1.10.2 on Fedora 23.
Is the above behavior of docker cp
intended or is it a bug? If it is intended, what's the reasoning behind it?
/
. – Ouzo