Last active
December 13, 2016 11:23
-
-
Save harishrathi/e0bef5565e64970fce02a8251b8aacfb to your computer and use it in GitHub Desktop.
docker hosting: mongo db in windows nanoserver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM microsoft/nanoserver | |
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] | |
ENV MONGO_VERSION 3.0.14 | |
ENV MONGO_DOWNLOAD_URL http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${MONGO_VERSION}-signed.msi | |
ENV MONGO_DOWNLOAD_SHA256 5a081722c42c79f23d9201c97500be6ddc8741b66ce707d88dad058bf84165f1 | |
RUN Write-Host ('Downloading {0} ...' -f $env:MONGO_DOWNLOAD_URL); \ | |
(New-Object System.Net.WebClient).DownloadFile($env:MONGO_DOWNLOAD_URL, 'mongo.msi'); \ | |
\ | |
Write-Host ('Verifying sha256 ({0}) ...' -f $env:MONGO_DOWNLOAD_SHA256); \ | |
if ((Get-FileHash mongo.msi -Algorithm sha256).Hash -ne $env:MONGO_DOWNLOAD_SHA256) { \ | |
Write-Host 'FAILED!'; \ | |
exit 1; \ | |
}; \ | |
\ | |
Write-Host 'Installing ...'; \ | |
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mongodb-community-edition | |
Start-Process msiexec -Wait \ | |
-ArgumentList @( \ | |
'/i', \ | |
'mongo.msi', \ | |
'/quiet', \ | |
'/qn', \ | |
'INSTALLLOCATION=C:\mongodb', \ | |
'ADDLOCAL=all' \ | |
); \ | |
$env:PATH = 'C:\mongodb\bin;' + $env:PATH; \ | |
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \ | |
\ | |
Write-Host 'Verifying install ...'; \ | |
Write-Host ' mongo --version'; mongo --version; \ | |
Write-Host ' mongod --version'; mongod --version; \ | |
\ | |
Write-Host 'Removing ...'; \ | |
Remove-Item C:\mongodb\bin\*.pdb -Force; \ | |
Remove-Item C:\windows\installer\*.msi -Force; \ | |
Remove-Item mongo.msi -Force; \ | |
\ | |
Write-Host 'Complete.'; | |
VOLUME C:\\data\\db C:\\data\\configdb | |
# TODO docker-entrypoint.ps1 ? (for "docker run <image> --flag --flag --flag") | |
EXPOSE 27017 | |
CMD ["mongod"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment