简体   繁体   中英

In Docker (for Windows) How can I add registry entries in bulk while building my image?

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"]

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.

Then try running Invoke-Command -ScriptBlock {regedit /i /s C:\\shared\\settings.reg}

The following is the only way I could getting working using 4.8-windowsservercore-ltsc2019

COPY Registry/ChromeConfiguration.reg .

RUN reg import ChromeConfiguration.reg

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