简体   繁体   中英

How to Create a Dockerfile to Run Docker in a Windows 2016 Container?

Background : Request is to use a Windows 2016 docker container to to build and deploy .net applications. The container will need to have various build tools installed(MSbuild...etc) and also docker as the .net application be pushed to the Azure Container Registry as containers.

Approach : My approach is to create a dockerfile with the various build tools and the docker service installed - set to start automatically when I run the container.

Here is an example of the dockerfile:

FROM microsoft/windowsservercore
MAINTAINER joe.user@nowhere.com

CMD powershell Start-Service Docker

SHELL ["powershell"]
RUN Invoke-WebRequest 
"https://download.microsoft.com/download/9/B/B/9BB1309E-1A8F-4A47-A6C5-ECF76672A3B3/BuildTools_Full.exe" -OutFile "$env:TEMP\net.exe" -UseBasicParsing
RUN &  "$env:TEMP\net.exe" /Silent /Full

# Note: Add NuGet
RUN Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force

RUN Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
RUN Install-Package -Name docker -ProviderName DockerMsftProvider -Force
RUN Set-Service -Name Docker -StartupType Automatic
#RUN Get-Service Docker
#RUN Restart-Computer -Force

Issue : It takes a restart to run the docker service I am not able to start the service building the docker file.

References : I am using the following URL's as reference to what commands should be run in the dockerfile.

Question : How do I start the docker service using a dockerfile? This doesn't seem to be possible from my testing. Has any anyone successfully started docker service in a Windows 2016 server? Any suggestions or examples on how to proceed would be must appreciated.

Thank you in advance for your assistance.

What you are referring to is called Docker-in-Docker. It is currently not supported for Windows (and is generally a bad idea for Linux)

https://github.com/docker-library/docker/issues/49 (I can't find anything from the MS end, but I'm guessing the docker folk know what they're talking about)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM