-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Problematic use of EvalSymlinks
on Windows
#2648
Comments
Signed-off-by: Eric Jonker <ericnl@live.com>
Signed-off-by: Eric <ericwj@users.noreply.github.com>
Since the behavior of
simply turned into (first attempt):
which is strange, since it actually successfully created On subsequent attempts, the error morphs into:
It looks like the workaround from golangci/golangci-lint#5245 might help here as well. |
@mbs-c that error is produced by the docker daemon, not the CLI; if you suspect there's a bug, it's better to open a ticket in https://github.com/moby/moby/issues with steps to reproduce. Does this setup work if you specify the actual location of the storage directory you want to use in the daemon's configuration ("data-root" property in |
@thaJeztah Sorry, I thought it would be relevant to mention it here, since this looked like a meta-issue for the root cause. I can file an additional bug report in the correct repository, if desired.
First of all, let me clarify that there is no symlink in the path, only a mount point. As I understand it, this is now (as of go 1.23 / docker v28) handled "correctly" by the go standard library in that it's no longer treated as a symbolic link. However, accessing paths containing mount points can still lead to Since my dev drive does not have a drive letter, there is no "actual location" I can specify other than the mount point
So there's currently no way for me to specify the "data-root" property in any way that docker will accept. |
Docker is using go's
path/filepath.EvalSymlinks
by default and remembers resolved symlink paths instead of the original path provided through the CLI by the user.On Windows, this is a severe problem which can lead to data loss, bypassing security and simply fails on current versions of go in all but the most trivial system configurations. See /golang/go/issues/40180 and the list of errors created by testing this API.
The most important use of
EvalSymlinks
is through the use of the API's listed below - I have only searched through /docker/cli, there may be other uses of eitherEvalSymlinks
directory or indirectly in this repo or others:The comment in
ResolveAndValidateContextPath
reads:There is not one good reason for this on Windows. The whole code section can simply be deleted and nothing will start failing - on the contrary, a long list of issues and potential issues will be fixed.
The more difficult issue to fix is that, also on Linux, the configured path is replaced by the path returned by
EvalSymlinks
, which is a bad practice. Docker should not preempt operational administrative actions from having effects by remembering only the resolved path, forgetting where it was configured to run from, or by caching the result ofEvalSymlinks
for any length of time.For Users: How to use
Docker
today, avoiding problems withEvalSymlinks
The very best thing to do is to give Docker only paths on volumes that are rooted at a drive letter, such as
C:\
orQ:\
. Obviously this severely drastically limits where Docker can run and gives no options to (re)configure the storage system if the need arises.isUNC
is linked above, not quite for being correct at all, but it checks that paths do not start with\\
- wrongfully conluding it must be a UNC path of the form\\server\share
.But any (absolute) path on Windows can be written to start with
\\
, hence it is possible to at least have Docker avoid the use ofEvalSymlinks
by changing the path given to the docker cli to include\\
:\\?\C:\ContextDir
\\?\Volume{00000000-0000-0000-0000-000000000000}\ContextDir
\\?\UNC\server\share\ContextDir
Note that this might or might not introduce other issues with go's very poorly ported
path/filepath
on Windows which is full of problems very much like the ones hinted at byisUnc
.Also, this does not fix issues with Docker when Docker is invoked by other tools such as Visual Studio that aren't so easy to configure to use any
\\
prefix consistently - and shouldn't have to be.For more information see File path formats on Windows systems | Microsoft Docs, amongst others. The prefix
\\.\
is also described. More technical information will also reveal\??\
is sometimes valid.Issues with Docker on Windows suspected to be caused by this issue
These are some of the existing issues with the use of this API - some are at least suspected to be caused by the use of
EvalSymlinks
in Docker:There are no issues that indicate any of the additional problems with the use of
EvalSymlinks
on Windows. Docker simply does not work unless the path it is given is to a volume that is mounted with a drive letter, unless the path starts with\\
:C:\FileServer\Share\BigFolders\Docker
in addition to\\?\Volume{00000000-0000-0000-0000-000000000000}\
\\?\UNC\...
.\\?\UNC\...
These situations may be desired by administrators using Docker on storage spaces
VirtualDisk
or Hyper-VVHD
virtual disks as well as on systems with more than one physical partition if they use GPT partitioning such as all 64-bit Windows editions.The text was updated successfully, but these errors were encountered: