Skip to content
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

Build mongo:3.4.0-nanoserver #124

Closed
StefanScherer opened this issue Dec 2, 2016 · 13 comments
Closed

Build mongo:3.4.0-nanoserver #124

StefanScherer opened this issue Dec 2, 2016 · 13 comments
Labels
enhancement question Usability question, not directly related to an error with the image Request Request for image modification or feature

Comments

@StefanScherer
Copy link
Contributor

After a longer investigation in https://jira.mongodb.org/browse/SERVER-27182 Mark Benvenuto found out that MongoDB 3.4 is working in NanoServer.

My approach uses a simple COPY deployment as the MSI package can't be installed in NanoServer.

How should an official Dockerfile look like?

@yosifkit
Copy link
Member

yosifkit commented Dec 3, 2016

If Visual C++ Redistributable 2015 is install-able in nanoserver, then we use that to get msvcp140.dll and vcruntime140.dll. We can then grab the mongo binaries directly from https://www.mongodb.org/dl/win32/x86_64-2008plus-ssl and we can also use the sha256 there to verify the download similar to the golang windows images.

Here is a quick untested copy from the golang image (still needs the download and extract of visual C++):

FROM microsoft/nanoserver

# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# PATH isn't actually set in the Docker image, so we have to set it from within the container
RUN $newPath = ('C:\mongodb\bin;{0}' -f $env:PATH); \
	Write-Host ('Updating PATH: {0}' -f $newPath); \
# Nano Server does not have "[Environment]::SetEnvironmentVariable()"
	setx /M PATH $newPath;
# doing this first to share cache across versions more aggressively

****** TODO, install Visual C++ Redistributable 2015 (and anything else that might be required)

ENV MONGO_VERSION 3.4.0
ENV MONGO_ARCHIVE_DIR mongodb-win32-x86_64-2008plus-ssl-${MONGO_VERSION}
ENV MONGO_DOWNLOAD_URL http://downloads.mongodb.org/win32/${MONGO_ARCHIVE_DIR}.zip
ENV MONGO_DOWNLOAD_SHA256 c4dd867fef653b8f3534ba563171179665486632814519a1c34228c5557f3ced

RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \
	Invoke-WebRequest -Uri $env:MONGO_DOWNLOAD_URL -OutFile 'mongo.zip'; \
	\
	Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \
	if ((Get-FileHash mongo.zip -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \
		Write-Host 'FAILED!'; \
		exit 1; \
	}; \
	\
	Write-Host 'Expanding ...'; \
	Expand-Archive mongo.zip -DestinationPath C:\; \
	Move-Item -Path ('C:\{0}' -f $env:MONGO_ARCHIVE_DIR) -Destination 'C:\mongodb'; \
	\
	Write-Host 'Verifying install ("mongo --version") ...'; \
	mongo --version; \
	\
	Write-Host 'Removing ...'; \
	Remove-Item mongo.zip -Force; \
	\
	Write-Host 'Complete.';

@StefanScherer
Copy link
Contributor Author

The ZIP file, although called "plus-ssl", lacks the OpenSSL DLL's. That's why I use the MSI and extract and copy everything into a smaller image.

$ docker run mongonanoserver cmd /c dir mongodb\\bin
 Volume in drive C has no label.
 Volume Serial Number is 3687-D732

 Directory of C:\mongodb\bin

12/03/2016  12:15 AM    <DIR>          .
12/03/2016  12:15 AM    <DIR>          ..
11/26/2016  01:56 PM         7,342,012 bsondump.exe
11/26/2016  02:09 PM        11,249,664 mongo.exe
11/26/2016  02:09 PM       111,939,584 mongo.pdb
11/26/2016  02:13 PM        26,959,360 mongod.exe
11/26/2016  02:13 PM       257,347,584 mongod.pdb
11/26/2016  01:58 PM         9,452,494 mongodump.exe
11/26/2016  01:57 PM         7,595,582 mongoexport.exe
11/26/2016  01:57 PM         7,517,729 mongofiles.exe
11/26/2016  01:57 PM         7,699,555 mongoimport.exe
11/26/2016  01:59 PM         7,342,596 mongooplog.exe
11/26/2016  02:14 PM        22,927,360 mongoperf.exe
11/26/2016  02:14 PM       231,919,616 mongoperf.pdb
11/26/2016  01:58 PM        10,789,806 mongorestore.exe
11/26/2016  02:13 PM        13,456,896 mongos.exe
11/26/2016  02:13 PM       126,758,912 mongos.pdb
11/26/2016  01:56 PM         7,669,925 mongostat.exe
11/26/2016  01:59 PM         7,476,490 mongotop.exe
              17 File(s)    875,445,165 bytes
               2 Dir(s)  21,270,663,168 bytes free

@tianon
Copy link
Member

tianon commented Dec 10, 2016

The problem with copying artifacts from windowsservercore into nanoserver is that we'll then need to commit those artifacts here (or otherwise publish them somewhere we can fetch) so that we can build the image properly with just a Dockerfile and it's relevant context directory. 😞

Does Microsoft not yet have an official (or even semi-official) solution for installing the Visual C++ runtime in Nano Server? 😞

For the SSL issue, we could punt for now and use the non-SSL releases from upstream (until we find a good way to extract their SSL DLLs directly, they include them, or we find compatible replacements somewhere), but the VC++ runtime issue is more pressing IMO because we can't run MongoDB at all without that, currently.

@StefanScherer
Copy link
Contributor Author

Don't know about the runtime. AFAIK they are only available as exe installers and may not be installable directly in nanoserver.

What about one CI build for both mongo:3.4.0-windowsservercore and mongo:3.4.0-nanoserver and copy the missing artifacts from the freshly built windowsservercore image to finalize the nanoserver image?
Still no single Dockerfile approach, but these artifacts only shortly live on build machine and not on GitHub.

@tianon
Copy link
Member

tianon commented Dec 10, 2016

If this repo were responsible for publishing artifacts directly, that would work, but if this repo were publishing artifacts directly, then different official images would have a difference cadence/process for updates (and make it hard for users to trace back to the Dockerfile which built the image); docker-library/hello-world#22 has some similar discussion of that problem.

@StefanScherer
Copy link
Contributor Author

In the meantime here is an inofficial Docker image for MongoDB 3.4.1 for nanoserver, built with AppVeyor + a Windows Docker engine running in Azure using this build.bat steps.
Image size is about 137MByte, so a download from Docker Hub feels pretty fast.

@StefanScherer
Copy link
Contributor Author

After the announcements at DockerCon (ok, I tried it a little earlier) I have put the NanoServer build into one multi-stage Dockerfile.
As soon as your CI pipeline has Docker 17.05 I can send you a PR.

Should we then provide only the nanoserver image for such products like MongoDB? IMHO then there is no need for a windowsservercore image.

@minherz
Copy link

minherz commented Jun 21, 2017

@StefanScherer I have tried to run your image stefanscherer/mongo-windows:3.4.4-nano on Docker for Windows in Windows10. It starts up correctly and the prints

2017-06-21T15:42:45.028+0300 W FTDC     [ftdc] Uncaught exception in 'FileRenameFailed: Access is denied' in full-time d
iagnostic data capture subsystem. Shutting down the full-time diagnostic data capture subsystem.

I am launching container with the following commandline:
docker run -it --rm --name mongodb stefanscherer/mongo-windows:3.4.4-nano

Do I miss some parameter(s)?

@StefanScherer
Copy link
Contributor Author

@minherz I tried it on Windows Server 2016 and I cannot find this error message in the logs. I also use a bind mount to have the data on the host. Maybe Windows Defender has disturbed the containerized processes?

mkdir mongo
docker container run -d -p 27017:27017 -v "$(pwd)\mongo:C:\data\db" --name mongodb stefanscherer/mongo-windows:3.4.4-nano
dir mongo
docker container logs $(docker container ls -lq)

@minherz
Copy link

minherz commented Jun 23, 2017

@StefanScherer I get the error when I run the image in Windows 10. In Windows Server 2016 it is running OK. I will check its work with explicit volume definition and not the temporary docker storage and will let you know.

@minherz
Copy link

minherz commented Jun 26, 2017

@StefanScherer running container with explicitly defined (and existing) volume location indeed worked for Windows 10.
Thank you

@yosifkit
Copy link
Member

Threading multistage build issue, docker-library/official-images#3383, since MongoDB on nanoserver would currently require that.

@wglambert wglambert added question Usability question, not directly related to an error with the image Request Request for image modification or feature labels Apr 24, 2018
@tianon
Copy link
Member

tianon commented Feb 18, 2022

This is fixed via #470 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement question Usability question, not directly related to an error with the image Request Request for image modification or feature
Projects
None yet
Development

No branches or pull requests

5 participants