microsoft/Windows-Containers

8dot3name short name creation not persisted

nbrinks opened this issue · 4 comments

Describe the bug
Creating a short name in a layer doesn't appear to persist in subsequent layers, nor is the short name resolvable when starting the container.

To Reproduce

Given a Dockerfile such as the following:

# escape=`
FROM mcr.microsoft.com/windows/server:ltsc2022
SHELL ["cmd", "/S", "/C"]

RUN fsutil file setshortname "C:/Program Files" "PROGRA~1" && `
    fsutil file setshortname "C:/Program Files (x86)" "PROGRA~2" && `
    DIR P* /X
RUN DIR P* /X

Build the image... e.g. docker build -t shortname-example --no-cache .

The build output:

Step 1/4 : FROM mcr.microsoft.com/windows/server:ltsc2022
 ---> 7370f2724f4c
Step 2/4 : SHELL ["cmd", "/S", "/C"]
 ---> Running in b545215c24c2
 ---> Removed intermediate container b545215c24c2
 ---> 9739fd112333
Step 3/4 : RUN fsutil file setshortname "C:/Program Files" "PROGRA~1" &&     fsutil file setshortname "C:/Program Files (x86)" "PROGRA~2" &&     DIR P* /X
 ---> Running in 07e794550b2b
 Volume in drive C has no label.
 Volume Serial Number is BE08-0509

 Directory of C:\

05/10/2024  03:50 PM    <DIR>          PROGRA~1     Program Files
05/10/2024  03:48 PM    <DIR>          PROGRA~2     Program Files (x86)
               0 File(s)              0 bytes
               2 Dir(s)  136,115,924,992 bytes free
 ---> Removed intermediate container 07e794550b2b
 ---> 41ed52b38f1a
Step 4/4 : RUN DIR P* /X
 ---> Running in 5558310de18c
 Volume in drive C has no label.
 Volume Serial Number is BE08-0509

 Directory of C:\

05/10/2024  03:50 PM    <DIR>                       Program Files
05/10/2024  03:48 PM    <DIR>                       Program Files (x86)
               0 File(s)              0 bytes
               2 Dir(s)  136,116,391,936 bytes free
 ---> Removed intermediate container 5558310de18c
 ---> 4df53e83def8
Successfully built 4df53e83def8
Successfully tagged shortname-example:latest

In the second DIR P* /X statement, the short names are gone.

Expected behavior
It is expected that the short names persist so they will resolve in subsequent layers. Also, that the short names can be used in the final image.

Configuration:

  • Edition: Windows 11 Enterprise, Version 23H2 (OS Build 22631.3593)
  • Base Image being used: Windows Server
  • Container engine: docker
  • Container Engine version: 25.0.2

Additional context
Strangely enough the short names used to resolve in the containers but suddenly stopped working recently. I haven't been able to pinpoint what exactly changed.

Currently using mklink /D "C:/PROGRA~1" "C:/Program Files" to work around this issue.

@nbrinks Hi, thanks for bringing up this Issue. We'd love to learn more about your use case. Can we ask why you're using short names in containers? And do you know when this feature stopped working for you?

@ntrappe-msft, We have some legacy build systems that use hardcoded short names. We are attempting to containerize our build environments. Our IT group has been making changes to the short name creation policy. Would changes to that have an impact on containers running with process isolation?

@nbrinks Thanks for sharing. I'm waiting to hear back from a few other engineers about whether short names not persisting is expected or not. I'll provide an update as soon as I can.

I should be able to provide an answer by the end of this week. I'm waiting on one other team to confirm that they're in agreement.