[英]In Docker (for Windows) How can I add registry entries in bulk while building my image?
我將 Docker 用於 Windows 並使用 Dockerfile 構建 docker 圖像,如下所示:
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 應用程序所需的數十個條目。 有沒有辦法以更簡潔的方式做到這一點?
嘗試為您的注冊表項創建文件,然后將其復制到容器中。
然后嘗試運行Invoke-Command -ScriptBlock {regedit /i /s C:\\shared\\settings.reg}
以下是我使用4.8-windowsservercore-ltsc2019
開始工作的唯一方法
COPY Registry/ChromeConfiguration.reg .
RUN reg import ChromeConfiguration.reg
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.