Skip to content

Windows: Don't follow junctions - #21040

Closed
lowenna wants to merge 1 commit into
moby:masterfrom
microsoft:jjh/junctions
Closed

lowenna wants to merge 1 commit into
moby:masterfrom
microsoft:jjh/junctions

Conversation

@lowenna

@lowenna lowenna commented Mar 8, 2016

Copy link
Copy Markdown
Member

Signed-off-by: John Howard [email protected]

Replacement for #18026, fixes #18120. @StefanScherer

image

@StefanScherer

Copy link
Copy Markdown
Contributor

@jhowardmsft Thank you. So nice! 🐕 and PR
I'm just building a new docker.exe, the latest Dockerfile.windows also looks pretty good. Haven't tried it for a while.

Comment thread pkg/archive/archive.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why id this deliberately not using logrus? It's used two lines below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I want it directly in the client output. Let me repro this evening and post up the difference and it will hopefully be obvious.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calavera As per this PR:

PS C:\users\Administrator\Documents> docker build -t test .
Skipping '\\?\C:\Users\Administrator\Documents\My Music' - Permission was denied
Skipping '\\?\C:\Users\Administrator\Documents\My Pictures' - Permission was denied
Skipping '\\?\C:\Users\Administrator\Documents\My Videos' - Permission was denied
Sending build context to Docker daemon 4.608 kB
Step 1 : FROM windowsservercore
 ---> 1757dfa56d73
Step 2 : ENTRYPOINT [ cmd.exe ]
 ---> Using cache
 ---> 142a116e6313
Successfully built 142a116e6313
PS C:\users\Administrator\Documents>

Using logrus

PS C:\users\Administrator\Documents> docker build -t test .
time="2016-03-08T18:24:29-08:00" level=error msg="Skipping '\\\\?\\C:\\Users\\Administrator\\Documents\\My Music' - Permission was denied\n"
time="2016-03-08T18:24:29-08:00" level=error msg="Skipping '\\\\?\\C:\\Users\\Administrator\\Documents\\My Pictures' - Permission was denied\n"
time="2016-03-08T18:24:29-08:00" level=error msg="Skipping '\\\\?\\C:\\Users\\Administrator\\Documents\\My Videos' - Permission was denied\n"
Sending build context to Docker daemon 4.608 kB
Step 1 : FROM windowsservercore
 ---> 1757dfa56d73
Step 2 : ENTRYPOINT [ cmd.exe ]
 ---> Using cache
 ---> 142a116e6313
Successfully built 142a116e6313
PS C:\users\Administrator\Documents>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't "skipping" files be a fatal error? i.e. As a user, I told Docker to build an image from the specified context, but Docker wasn't able to complete that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment, but I believe this is the right fix for junctions on Windows.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except you're sending it to os.Stdout rather than to the output stream configured by the build context, like in the code you pointed. Printing that output should be handled by the caller not by this function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, you're right. Will fix up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, removed it. Getting it back to the caller is extremely problematic unless I change the interface to TarWithOptions, which may very likely be called from components outside of the engine. I only added it in the first place (compared with the original PR) to give a little user feedback, but it's really not essential.

@icecrime

icecrime commented Mar 9, 2016

Copy link
Copy Markdown
Contributor

I'm not sure if this is new:

16:11:19 FAIL: docker_cli_start_test.go:147: DockerSuite.TestStartAttachMultipleContainers
16:11:19 
16:11:19 docker_cli_start_test.go:150:
16:11:19     runSleepingContainer(c, "--name", container)
16:11:19 C:/gopath/src/github.com/docker/docker/pkg/integration/dockerCmd_utils.go:42:
16:11:19     c.Assert(err, check.IsNil, check.Commentf(quote+"%v"+quote+" failed with errors: %s, %v", strings.Join(args, " "), out, err))
16:11:19 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc0823fa5a0), Stderr:[]uint8(nil)} ("exit status 125")
16:11:19 ... "run -d --name test3 busybox sleep 120" failed with errors: 2450fe27442c7428bfc61ee4c7b47f6eff11d7d831df4c5b497e0cebee73d16a
16:11:19 D:\CI\CI-1a9c96c\binary\docker.exe: Error response from daemon: Cannot start container 2450fe27442c7428bfc61ee4c7b47f6eff11d7d831df4c5b497e0cebee73d16a: HCSShim::CreateProcessInComputeSystem failed in Win32: The specified path is invalid. (0xa1) id=2450fe27442c7428bfc61ee4c7b47f6eff11d7d831df4c5b497e0cebee73d16a params={ C:/busybox/busybox.exe sleep 120  map[] false [0 0]}.
16:11:19 , exit status 125

@lowenna

lowenna commented Mar 9, 2016

Copy link
Copy Markdown
Member Author

@icecrime Not related. I'll restart.

@StefanScherer

Copy link
Copy Markdown
Contributor

With latest docker.exe built from master:

PS C:\Users\vagrant\Documents> type .\Dockerfile
FROM windowsservercore:10.0.10586.0
RUN dir
CMD ["cmd.exe"]
PS C:\Users\vagrant\Documents> docker build -t test .
Error checking context: 'can't stat '\\?\C:\Users\vagrant\Documents\My Music''.
PS C:\Users\vagrant\Documents> docker version
Client:
 Version:      1.11.0-dev
 API version:  1.23
 Go version:   go1.6
 Git commit:   3d09842-unsupported
 Built:        Tue Mar  8 23:09:03 2016
 OS/Arch:      windows/amd64

And the Docker Client aborts before sending data to the Docker Engine.

With this PR:

PS C:\Users\vagrant\Documents> type .\Dockerfile
FROM windowsservercore:10.0.10586.0
RUN dir
CMD ["cmd.exe"]
PS C:\Users\vagrant\Documents> docker build -t test .
An error occurred trying to connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.23/build?buildargs=%7B%7D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&memory=0&memswap=0&rm=1&shmsize=0&t=test&ulimits=null: open //./pipe/docker_engine: The system cannot find the file specified.
PS C:\Users\vagrant\Documents> docker -H tcp://localhost:2375 build -t test .
Skipping '\\?\C:\Users\vagrant\Documents\My Music' - Permission was denied
Skipping '\\?\C:\Users\vagrant\Documents\My Pictures' - Permission was denied
Skipping '\\?\C:\Users\vagrant\Documents\My Videos' - Permission was denied
Sending build context to Docker daemon 4.608 kB
Step 1 : FROM windowsservercore:10.0.10586.0
 ---> 09d8cbd274d8
Step 2 : RUN dir
 ---> Running in d2a54d187afd
 Volume in drive C has no label.
 Volume Serial Number is E6D1-ADC3
...

And the Docker image can be built.

BTW: @jhowardmsft I have to use -H tcp://localhost:2375 on a TP4 machine. The Docker Client now only tries to use the pipe. My daemon currently runs with docker daemon -D -b "Virtual Switch" -H 0.0.0.0:2375 --insecure-registry registry:5000. I think I have to update my setup.

@StefanScherer

Copy link
Copy Markdown
Contributor

Is there a similar behaviour on Linux if the Client can't read a file/dir/symlink/link/... ?

@thaJeztah

Copy link
Copy Markdown
Member

@StefanScherer yes, for example, if a symlink points to files outside of the build context, the build will fail; e.g. #1676 (and #18789)

@lowenna

lowenna commented Mar 9, 2016

Copy link
Copy Markdown
Member Author

@StefanScherer The default wire protocol was switched from TCP to npipe last week. So yes, remove that -H from the daemon.

@lowenna

lowenna commented Mar 9, 2016

Copy link
Copy Markdown
Member Author

@thaJeztah

To be clear, this is not a symlink, but a junction. Similar though. Further, in this case, the PR is catering for a junction which cannot be enumerated due to a shortcoming in golangs handling of long file paths. It's irrelevant whether they are inside or outside the scope as it can't even be enumerated in the first place. Symlinks pointing to outside the build context -will- fail on Windows.

C:\test>dir
 Volume in drive C is Z420 Boot SSD
 Volume Serial Number is 8A33-F015

 Directory of C:\test

03/09/2016  09:01 AM    <DIR>          .
03/09/2016  09:01 AM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  306,101,776,384 bytes free

C:\test>mklink /d foo c:\windows\system32
symbolic link created for foo <<===>> c:\windows\system32

C:\test>dir
 Volume in drive C is Z420 Boot SSD
 Volume Serial Number is 8A33-F015

 Directory of C:\test

03/09/2016  09:02 AM    <DIR>          .
03/09/2016  09:02 AM    <DIR>          ..
03/09/2016  09:02 AM    <SYMLINKD>     foo [c:\windows\system32]
               0 File(s)              0 bytes
               3 Dir(s)  306,101,276,672 bytes free

C:\test>rmdir foo

C:\test>
C:\Users\jhoward\Documents>dir /ah
 Volume in drive C is Z420 Boot SSD
 Volume Serial Number is 8A33-F015

 Directory of C:\Users\jhoward\Documents

02/23/2016  12:50 PM             2,248 Default.rdp
02/26/2016  06:18 PM               402 desktop.ini
02/26/2016  04:41 PM    <JUNCTION>     My Music [C:\Users\jhoward\Music]
02/26/2016  04:41 PM    <JUNCTION>     My Pictures [C:\Users\jhoward\Pictures]
02/26/2016  04:41 PM    <JUNCTION>     My Videos [C:\Users\jhoward\Videos]
04/30/2015  07:32 AM             2,248 WTTJobMonitorMachine.RDP
               3 File(s)          4,898 bytes
               3 Dir(s)  306,099,441,664 bytes free

C:\Users\jhoward\Documents>

@StefanScherer

Copy link
Copy Markdown
Contributor

@jhowardmsft I will try that. But what about using Docker with TLS. Can I start the daemon with multiple endpoints for npipe locally + TLS ? I will try that later as well.

@lowenna

lowenna commented Mar 9, 2016

Copy link
Copy Markdown
Member Author

Yes re multiple npipe endpoints. I believe they work with TLS, but have not verified myself (I didn't work on the npipe implementation apart from the changes to switch over the default transport).

@StefanScherer

Copy link
Copy Markdown
Contributor

After updating the C:\ProgramData\docker\runDockerDaemon.cmd by adding -H npipe:////./pipe/docker_engine to the docker daemon command the local Docker Client is able to talk to the Engine again without any additional arguments.

Example for TLS:

:secure
docker daemon -D -b "Virtual Switch" -H npipe:////./pipe/docker_engine -H tcp://0.0.0.0:2376 --tlsverify --tlscacert=%certs%\ca.pem --tlscert=%certs%\server-cert.pem --tlskey=%certs%\server-key.pem

@thaJeztah

Copy link
Copy Markdown
Member

@jhowardmsft oh, sorry, the "follow symlinks outside context" was just an example to show that we fail if files cannot be used in the build context.

I still wonder if proceeding the build is the right approach, as the build does not include all the files that the user requested to use in the build context. IMO, failing would give the right signal to the user: "you need to build from a different directory, or fix the unreachable paths, to build your image")

Is there a reason we want to continue the build in this situation?

@mlaventure

Copy link
Copy Markdown
Contributor

TP4 failure looks genuine.

@mlaventure mlaventure added the status/failing-ci Indicates that the PR in its current state fails the test suite label Mar 10, 2016
@mlaventure

Copy link
Copy Markdown
Contributor

Actually, it may not be. @jhowardmsft wdyt?

@lowenna

lowenna commented Mar 10, 2016

Copy link
Copy Markdown
Member Author

@mlaventure No, that's a known bug in TP4 which frequently hits runs. Not related.

@lowenna

lowenna commented Mar 10, 2016

Copy link
Copy Markdown
Member Author

@thaJeztah Obviously there's contention here from your perspective. I don't have a strong opinion either way. If maintainers choose not to take it, that's really your guys decision. I was just fixing a reported issue...

@mlaventure mlaventure removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Mar 10, 2016
@thaJeztah

Copy link
Copy Markdown
Member

@jhowardmsft I think we should either fix the situation (being able to use those files), or error out and provide a useful error message to the user. Just my 0.02c

For the longer term; Do we know where the bug is in Golang? Can we help fixing that bug so that we can fix the actual issue?

@calavera

Copy link
Copy Markdown
Contributor

I agree with @thaJeztah. Failing fast sounds more ideal and probably more expected. Otherwise, people might find themselves with images lacking files they expect to be there.

@StefanScherer

Copy link
Copy Markdown
Contributor

At the time I filed the issue #18120 I thought this is windows specific. I tried a similar situation from a Mac building a Linux image with a protected folder and also found out that the Docker client aborts.

So it seems writing a Dockerfile in the users's Documents folder is just a bad luck for the user as there are hidden links in it. Solution is to create another directory. I'm happy with anything you decide here.

@thaJeztah

Copy link
Copy Markdown
Member

@StefanScherer thanks. I think this PR is still useful, because we can detect the problem and give a more user-friendly error message ('can't stat '\\?\C:\Users\vagrant\Documents\My Music' is a bit cryptical). So I'm +1 for aborting the build so that the user stays in charge and can fix the situation by using a different folder. Uploading the entire Music and Pictures collection probably isn't the best thing to do in most cases, so 😄

@StefanScherer

Copy link
Copy Markdown
Contributor

🎶

@thaJeztah

Copy link
Copy Markdown
Member

ping @jhowardmsft :)

@thaJeztah

Copy link
Copy Markdown
Member

ping @jhowardmsft do we need this to improve the error message, but keep the "fail fast" behavior?

@lowenna

lowenna commented Apr 21, 2016

Copy link
Copy Markdown
Member Author

Closing. Sounds like this is by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TP4 docker client doesn't like My Music

7 participants