[SERVER-27182] Support MongoDB running in Windows Nanoserver, Windows Container Created: 25/Nov/16  Updated: 05/Apr/17  Resolved: 06/Dec/16

Status: Closed
Project: Core Server
Component/s: Portability
Affects Version/s: 3.2.11
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: stefanscherer [X] Assignee: Mark Benvenuto
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on WT-3042 Use MoveFileExW instead of MoveFileW ... Closed
Related
Backwards Compatibility: Fully Compatible
Sprint: Platforms 2017-01-23
Participants:

 Description   

I recently helped to minimize the official Docker image "mongo" to run MongoDB in a Windows container: https://github.com/docker-library/mongo/blob/21a6f6cf3eff13a39b20c86224730a29823370ca/3.2/windows/windowsservercore/Dockerfile

And then I tried to put MongoDB into a Windows Nanoserver container, but the binaries do not start.

It would be great to have MongoDB running in Nanoserver as well.

If there is some progress please let me know. Otherwise I can try to investigate what's wrong running MongoDB in Nanoserver.



 Comments   
Comment by stefanscherer [X] [ 05/Dec/16 ]

I'm fine with it closing this issue. Thanks for your help.

Comment by Chad Kreimendahl [ 05/Dec/16 ]

I'd love to see a how-to guide on the main documentation website to go with this

Comment by Mark Benvenuto [ 05/Dec/16 ]

Thank you for the work Stefan. I am planning to close the ticket since everything works with 3.4.0. Let me know if you would like to keep the ticket open.

Comment by stefanscherer [X] [ 02/Dec/16 ]

Opened https://github.com/docker-library/mongo/issues/124 for an official Dockerfile and Docker image.

Comment by stefanscherer [X] [ 02/Dec/16 ]

Added interim Docker images at https://hub.docker.com/r/stefanscherer/mongo-windows/ until we have an official mongo:3.4.0-nanoserver

Comment by stefanscherer [X] [ 02/Dec/16 ]

Oh, that's great! Yes, indeed, I can confirm that. I missed the vcruntime140.dll yesterday.
Yes the forwarder DLL's are part of the nanoserver image, so it is easier to make programs run.
I don't know how long the forwarder DLL's will be available, but now we have a first working version in Nano.

Comment by Mark Benvenuto [ 02/Dec/16 ]

I validated that 3.4.0 with and without SSL starts successfully in Windows Nano Server image. As long as the binaries are linked against the Visual Studio 2015 runtime (vcruntime140), they will work fine. I am surprised even though the API scanner complains. I believe this is possible because the reverse forwarder is installed.

The 3.2. and 3.0 binaries will not work since they are linked against the Visual Studio runtime (mscvcrt120.dll).

Comment by stefanscherer [X] [ 30/Nov/16 ]

I did a short test with the OpenSSL 64bit binaries for Windows, and I put them into a nanoserver container. They seem to work, with warnings in the NanoServerApiScan tool. OK, I couldn't test the two DLL's that MongoDB uses with it.

I think for a first step it would be sufficient to use the forwarder DLL's as they are part of the nanoserver container, so nobody would "uninstall" them from the base image.

PS C:\openssl\bin> dir
 
 
    Directory: C:\openssl\bin
 
 
Mode                LastWriteTime         Length Name                                                              
----                -------------         ------ ----                                                              
d-----       10/19/2016  12:41 PM                PEM                                                               
-a----        9/26/2016   9:39 AM           6952 CA.pl                                                             
-a----        9/26/2016   9:39 AM          56832 capi.dll                                                          
-a----        9/26/2016   9:39 AM          34816 dasync.dll                                                        
-a----        9/26/2016   9:39 AM        2877952 libcrypto-1_1-x64.dll                                             
-a----        9/26/2016   9:39 AM         477696 libssl-1_1-x64.dll                                                
-a----        9/26/2016   9:39 AM         963232 msvcr120.dll                                                      
-a----        9/26/2016   9:39 AM          10771 openssl.cfg                                                       
-a----        9/26/2016   9:39 AM         481792 openssl.exe                                                       
-a----        9/26/2016   9:39 AM          31232 ossltest.dll                                                      
-a----        9/26/2016   9:39 AM          41472 padlock.dll                                                       
-a----        9/26/2016   9:39 AM           4473 progs.pl                                                          
-a----        9/26/2016   9:39 AM           6815 tsget.pl                                                          
 
 
PS C:\openssl\bin> exit
~/code/dockerfiles-windows/openssl on master*
$ ls
Dockerfile      Dockerfile.nano README.md       tmp
~/code/dockerfiles-windows/openssl on master*
$ cd tmp
~/code/dockerfiles-windows/openssl/tmp on master*
$ echo "FROM stefanscherer/nanoserverapiscan:onbuild" > Dockerfile
~/code/dockerfiles-windows/openssl/tmp on master*
$ docker build -t sslcheck .
Sending build context to Docker daemon 9.766 MB
Step 1/1 : FROM stefanscherer/nanoserverapiscan:onbuild
# Executing 1 build trigger...
Step 1/1 : COPY . /scan
 ---> 6f0b0ba54057
Removing intermediate container 63cb725891c1
Successfully built 6f0b0ba54057
~/code/dockerfiles-windows/openssl/tmp on master*
$ docker run sslcheck
Error: the file "C:\scan\unins000.exe" is not a valid 64 bit PE file.
-----------------------------------------------------------------------------
=== libcrypto-1_1-x64.dll ===
=== C:\scan\libcrypto-1_1-x64.dll ===
 
ERRORS:
 
  ADVAPI32.dll
    ReportEventW(Proc not found)
    RegisterEventSourceW(Proc not found)
    DeregisterEventSource(Proc not found)
  USER32.dll
    MessageBoxW(Proc not found)
    GetUserObjectInformationW(Proc not found)
    GetProcessWindowStation(Proc not found)
  KERNEL32.dll
    GlobalMemoryStatus(Proc not found)
      Please use API GlobalMemoryStatusEx as substitution.
 
-----------------------------------------------------------------------------
=== libssl-1_1-x64.dll ===
=== C:\scan\libssl-1_1-x64.dll ===
 
 
-----------------------------------------------------------------------------
=== capi.dll ===
=== C:\scan\bin\capi.dll ===
 
 
-----------------------------------------------------------------------------
=== dasync.dll ===
=== C:\scan\bin\dasync.dll ===
 
 
-----------------------------------------------------------------------------
=== libcrypto-1_1-x64.dll ===
=== C:\scan\bin\libcrypto-1_1-x64.dll ===
 
ERRORS:
 
  ADVAPI32.dll
    ReportEventW(Proc not found)
    RegisterEventSourceW(Proc not found)
    DeregisterEventSource(Proc not found)
  USER32.dll
    MessageBoxW(Proc not found)
    GetUserObjectInformationW(Proc not found)
    GetProcessWindowStation(Proc not found)
  KERNEL32.dll
    GlobalMemoryStatus(Proc not found)
      Please use API GlobalMemoryStatusEx as substitution.
 
-----------------------------------------------------------------------------
=== libssl-1_1-x64.dll ===
=== C:\scan\bin\libssl-1_1-x64.dll ===
 
 
-----------------------------------------------------------------------------
=== msvcr120.dll ===
=== C:\scan\bin\msvcr120.dll ===
 
ERRORS:
 
  KERNEL32.dll
    UnregisterWait(Proc not found)
      Please use API UnregisterWaitEx as substitution.
    RegisterWaitForSingleObject(Proc not found)
    GetProcessAffinityMask(Proc not found)
    SetThreadAffinityMask(Proc not found)
      Please use API SetThreadGroupAffinity as substitution.
    SetProcessAffinityMask(Proc not found)
 
-----------------------------------------------------------------------------
=== openssl.exe ===
=== C:\scan\bin\openssl.exe ===
 
ERRORS:
 
  KERNEL32.dll
    MoveFileW(Proc not found)
      Please use API MoveFileExW as substitution.
 
-----------------------------------------------------------------------------
=== ossltest.dll ===
=== C:\scan\bin\ossltest.dll ===
 
 
-----------------------------------------------------------------------------
=== padlock.dll ===
=== C:\scan\bin\padlock.dll ===

Comment by Mark Benvenuto [ 30/Nov/16 ]

Thank you for detailed information.

There are a few different types of programs included in the MongoDB distribution. They are in roughly three categories: C++ programs, Go programs, and third-party.

These are all Go, and so these depend on the Go compiler runtime.

  1. mongoexport.exe
  2. mongooplogexe
  3. mongostat.exe
  4. mongofiles.exe
  5. mongotop.exe
  6. mongodump.exe
  7. mongoimport.exe
  8. mongorestore.exe

These are third-party dlls that we ship:

  1. msvcp120.dll - MSVC 2013 C++ Support library
  2. msvcr120.dll - MSVC 2013 C Runtime library
  3. ssleay32.dll - OpenSSL
  4. libeay32.dll - OpenSSL

I do not know if MSVC 2013 supports nano server. MongoDB 3.4 is compiled with MSVC 2015 so this may be simply fixed in this later version. On the other hand, OpenSSL cannot be easily fixed, but we may move away from OpenSSL in the future. Otherwise, only a non-SSL build would work.

In the C++ program category:

  1. mongo.exe
  2. mongod.exe
  3. mongos.exe (not in your list)

Most of the of problematic API calls come from our GPerfTools component, and need to work with gperftools to support Windows Nano Server. The MoveFileW call comes from WiredTiger and I opened WT-3042 to fix this. The MongoD ADVAPI32 calls could be likely be removed.

Comment by stefanscherer [X] [ 25/Nov/16 ]

I found the NanoServerApiScan tool https://blogs.technet.microsoft.com/nanoserver/2016/04/27/nanoserverapiscan-exe-updated-for-tp5/ and put it into a Docker image https://github.com/StefanScherer/dockerfiles-windows/tree/master/nanoserverapiscan

Here is the output of the scan that shows with API's have to be updated to work in Nano Server.

$ ls
Dockerfile       mongo.exe        mongoexport.exe  mongooplog.exe   mongostat.exe    msvcr120.dll
bsondump.exe     mongod.exe       mongofiles.exe   mongoperf.exe    mongotop.exe     ssleay32.dll
libeay32.dll     mongodump.exe    mongoimport.exe  mongorestore.exe msvcp120.dll
~/code/dockerfiles-windows/mongo/3.2/build/mongodb/bin on master
$ docker build -t mongoscan .
Sending build context to Docker daemon 120.6 MB
Step 1/1 : FROM nanoserverapiscan:onbuild
# Executing 1 build trigger...
Step 1/1 : COPY . /scan
 ---> 686cadf82953
Removing intermediate container 8816719dc996
Successfully built 686cadf82953
~/code/dockerfiles-windows/mongo/3.2/build/mongodb/bin on master
$ docker run mongoscan
-----------------------------------------------------------------------------
=== bsondump.exe ===
=== C:\scan\bsondump.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== libeay32.dll ===
=== C:\scan\libeay32.dll ===
 
ERRORS:
 
  GDI32.dll
    SelectObject(Proc not found)
    GetDeviceCaps(Proc not found)
    GetBitmapBits(Proc not found)
    DeleteObject(Proc not found)
    DeleteDC(Proc not found)
    CreateDCW(Proc not found)
    CreateCompatibleDC(Proc not found)
    CreateCompatibleBitmap(Proc not found)
    BitBlt(Proc not found)
    GetObjectW(Proc not found)
  ADVAPI32.dll
    RegisterEventSourceW(Proc not found)
    DeregisterEventSource(Proc not found)
    ReportEventW(Proc not found)
  USER32.dll
    GetDesktopWindow(Proc not found)
    MessageBoxW(Proc not found)
    GetUserObjectInformationW(Proc not found)
    GetProcessWindowStation(Proc not found)
  KERNEL32.dll
    GlobalMemoryStatus(Proc not found)
      Please use API GlobalMemoryStatusEx as substitution.
 
-----------------------------------------------------------------------------
=== mongo.exe ===
=== C:\scan\mongo.exe ===
 
ERRORS:
 
  KERNEL32.dll
    Module32First(Proc not found)
    CreateToolhelp32Snapshot(Proc not found)
    Module32Next(Proc not found)
  SHELL32.dll
    SHGetFolderPathW(Proc not found)
  SHLWAPI.dll
    SHGetValueA(Proc not found)
 
-----------------------------------------------------------------------------
=== mongod.exe ===
=== C:\scan\mongod.exe ===
 
ERRORS:
 
  ADVAPI32.dll
    ReportEventW(Proc not found)
    RegisterEventSourceW(Proc not found)
  KERNEL32.dll
    MoveFileW(Proc not found)
      Please use API MoveFileExW as substitution.
    VerifyVersionInfoW(Proc not found)
    CreateToolhelp32Snapshot(Proc not found)
    Module32First(Proc not found)
    Module32Next(Proc not found)
  SHLWAPI.dll
    SHGetValueA(Proc not found)
 
-----------------------------------------------------------------------------
=== mongodump.exe ===
=== C:\scan\mongodump.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== mongoexport.exe ===
=== C:\scan\mongoexport.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== mongofiles.exe ===
=== C:\scan\mongofiles.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== mongoimport.exe ===
=== C:\scan\mongoimport.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== mongooplog.exe ===
=== C:\scan\mongooplog.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== mongoperf.exe ===
=== C:\scan\mongoperf.exe ===
 
ERRORS:
 
  KERNEL32.dll
    MoveFileW(Proc not found)
      Please use API MoveFileExW as substitution.
    VerifyVersionInfoW(Proc not found)
    CreateToolhelp32Snapshot(Proc not found)
    Module32First(Proc not found)
    Module32Next(Proc not found)
  SHLWAPI.dll
    SHGetValueA(Proc not found)
 
-----------------------------------------------------------------------------
=== mongorestore.exe ===
=== C:\scan\mongorestore.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== mongostat.exe ===
=== C:\scan\mongostat.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== mongotop.exe ===
=== C:\scan\mongotop.exe ===
 
ERRORS:
 
  KERNEL32.dll
    GetProcessAffinityMask(Proc not found)
    GetStartupInfoA(Proc not found)
      Please use API GetStartupInfoW as substitution.
 
-----------------------------------------------------------------------------
=== msvcp120.dll ===
=== C:\scan\msvcp120.dll ===
 
 
-----------------------------------------------------------------------------
=== msvcr120.dll ===
=== C:\scan\msvcr120.dll ===
 
ERRORS:
 
  KERNEL32.dll
    UnregisterWait(Proc not found)
      Please use API UnregisterWaitEx as substitution.
    RegisterWaitForSingleObject(Proc not found)
    GetProcessAffinityMask(Proc not found)
    SetThreadAffinityMask(Proc not found)
      Please use API SetThreadGroupAffinity as substitution.
    SetProcessAffinityMask(Proc not found)
 
-----------------------------------------------------------------------------
=== ssleay32.dll ===
=== C:\scan\ssleay32.dll ===

Comment by stefanscherer [X] [ 25/Nov/16 ]

Here is a good starting point how to port Win32 apps to Nanoserver https://blogs.technet.microsoft.com/windowsserver/2015/11/16/moving-to-nano-server-the-new-deployment-option-in-windows-server-2016/

Comment by stefanscherer [X] [ 25/Nov/16 ]

Here is my setup to build minimal Docker images for both windowsservercore and nanoserver https://github.com/StefanScherer/dockerfiles-windows/tree/master/mongo/3.2

$ ./build.sh
...
Check windowsservercore
db version v3.2.11
git version: 009580ad490190ba33d1c6253ebd8d91808923e4
OpenSSL version: OpenSSL 1.0.1t-fips  3 May 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: 2008plus-ssl
    distarch: x86_64
    target_arch: x86_64
Check nanoserver
$ 

Generated at Thu Feb 08 04:14:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.