2

I am mounting volume in docker container and then trying to create a symbolic link for a directory but it gives protocol error. This docker image/container I am running on windows7.

artifacts is mounted in docker with -v option while running the docker.

root@0946d7a3022b:/artifacts# mkdir a
root@0946d7a3022b:/artifacts# mkdir b
root@0946d7a3022b:/artifacts# chmod 777 a
root@0946d7a3022b:/artifacts# chmod 777 b
root@0946d7a3022b:/artifacts# ln -s b a
ln: failed to create symbolic link 'a/b': Protocol error
root@0946d7a3022b:/artifacts# ln -s a b
ln: failed to create symbolic link 'b/a': Protocol error

I copied /artifacts to some other folder /testhere and then tried the same thing, it dint give any error.

root@0946d7a3022b:/testhere# mkdir a
root@0946d7a3022b:/testhere# mkdir b
root@0946d7a3022b:/testhere# ln -s a b
root@0946d7a3022b:/testhere# ln -s b a

This alternative solution increases overhead of copying mounted folder to some other folder inside docker container. Can someone suggest any solution for this issue?

  • For me, running as administrator was not enough, and I still got "Protocol error" when trying to create symlinks. Here was what worked: https://stackoverflow.com/a/60741351/470749 I was using Homestead vagrant instead of Docker, but it might be similar. – Ryan Mar 18 '20 at 14:19

1 Answers1

2

ln: Protocol error happens because you have to be administrator on your Windows Docker host to be able to create symlinks (which you are not even though you are root in your Docker container).

If you are running Docker on Windows 7, I guess you still use Docker Toolbox relying on VirtualBox. You can either:

  • Run VirtualBox as administrator, and then start your Boot2Docker VM from there (you may have to add this existing VM in the Virtualbox session first)
  • Or, if it's a one-shot command, create your symlink directly from an administrator cmd on your Windows Docker host, with mklink, it will be seen as a regular symlink in your Docker container.
alleen1
  • 418
  • 6
  • 14