在Docker(对于Windows)如何在构build映像时批量添加registry项?

我使用Docker for Windows并使用Dockerfile构buildDocker镜像,如下所示:

FROM mydockerhublogin/win2k16-ruby:1.0 # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app ADD . /app # Make port 80 available to the world outside this container EXPOSE 80 # Define environment variable ENV NAME World RUN powershell -Command \ $ErrorActionPreference = 'Stop'; \ New-Item "HKLM:\Software\WOW6432Node\ExampleCom" -Force ; \ New-ItemProperty "HKLM:\Software\WOW6432Node\ExampleCom" -Name MenuLastUpdate -Value "test" -Force RUN powershell -Command \ $ErrorActionPreference = 'Stop'; \ New-Item "HKLM:\Software\ExampleCom" -Force ; \ New-ItemProperty "HKLM:\Software\ExampleCom" -Name MenuLastUpdate -Value "test" -Force # Run ruby script when the container launches CMD ["C:/Ruby23-x64/bin/ruby.exe", "docker_ruby_test.rb"] 

请注意,我将一些registry项添加到容器中的代码将访问的Windowsregistry中。 虽然这种添加registry项的方法对于一些条目来说是好的,但我的要求是添加我的Windows应用程序所需的许多条目。 有没有办法以更简洁的方式做到这一点?

尝试为您的registry项创build一个文件,并将其复制到容器中。

然后尝试运行Invoke-Command -ScriptBlock {regedit /i /s C:\shared\settings.reg}