在Docker(对于Windows)中,如何在构建映像时批量添加注册表项? [英] In Docker (for Windows) How can I add registry entries in bulk while building my image?
问题描述
我正在使用适用于Windows的Docker并使用这样的Dockerfile构建Docker映像:
I'm using Docker for Windows and building the docker image with a Dockerfile like this:
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"]
请注意,正在向Windows注册表添加一些注册表项,容器内的代码将访问这些注册表项。尽管此添加注册表项的方法仅适用于一些条目,但我的要求是添加Windows应用程序所需的数十个条目。有没有一种更简洁的方法?
Note that I am adding some registry entries to the Windows registry which the code inside the container will access. While this method of adding registry entries is fine for a few entries, my requirement is to add dozens of entries required for my windows application. Is there a way to do this in a more concise manner?
推荐答案
尝试为您的注册表项创建文件并复制该文件在容器内。
Try creating a file for the your registry entry and copy that inside the container.
然后尝试运行 Invoke-Command -ScriptBlock {regedit / i / s C:\shared\settings.reg}
这篇关于在Docker(对于Windows)中,如何在构建映像时批量添加注册表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!