导入的文件不会出现在Docker容器中

我昨天第一次碰到Docker,对于一般的Web服务器pipe理我不太了解。 只是一个头。

我努力在Docker容器中运行一个简单的PHP“hello world”。 我已经用下面的dockerfile构build了一个Docker容器:

FROM nanoserver/iis MAINTAINER nanoserver.es@gmail.com ADD http://windows.php.net/downloads/releases/php-5.6.31-Win32-VC11-x64.zip php.zip ADD https://nanoserver.es/nanofiles/vcruntime140.dll C:\\Windows\\System32\\vcruntime140.dll ADD https://nanoserver.es/nanofiles/iisfcgi.dll C:\\Windows\\System32\\inetsrv\\iisfcgi.dll ADD https://nanoserver.es/nanofiles/info.dll C:\\inetpub\\wwwroot\\info.php COPY hello.php C:\\inetpub\\wwwroot\\hello.php ENV PHP C:\\php RUN powershell -command Expand-Archive -Path c:\php.zip -DestinationPath C:\php RUN setx PATH /M %PATH%;C:\php ADD https://nanoserver.es/nanofiles/php.ini C:\\php\\php.ini RUN powershell -command \ rm C:\Windows\System32\inetsrv\config\Applicationhost.config ; \ Invoke-WebRequest -uri https://nanoserver.es/nanofiles/Applicationhost.txt -outfile C:\\Windows\\System32\\inetsrv\\config\\Applicationhost.config ; \ Remove-Item c:\php.zip -Force # The above request fails, but I don't see how it would be relevant to my question. CMD ["powershell.exe"] 

我期望这个Dockerfile创build一个容器与c:\ inetpub \ wwwroot \ info.php,c:\ inetpub \ wwwroot \ hello.php和c:\ php。 但是,容器内的Powershell给了我这个输出:

 PS C:\inetpub\wwwroot> ls Directory: C:\inetpub\wwwroot Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 4/11/2017 11:55 AM 703 iisstart.htm -a---- 4/11/2017 11:55 AM 99710 iisstart.png 

感觉就像我还没有掌握一些基本的东西。 有人可以帮我吗?

在Windows上,你必须在Dockerfilepath中使用正斜杠。

官方文档: https : //docs.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile

从文档

在Windows上,目标格式必须使用正斜杠。 例如,这些是有效的COPY指令。

 COPY test1.txt /temp/ COPY test1.txt c:/temp/ 

但是,以下将无法正常工作。

 COPY test1.txt c:\temp\ 

如果源或目标包含空格,请将path括在方括号和双引号中。

 COPY ["<source>", "<destination>"] 

另外请注意,复制到图像中不存在的path通常不会触发错误。 该目录必须存在。