windows - 在 Docker(适用于 Windows)中,如何在构建镜像时批量添加注册表项?

标签 windows docker registry

我正在使用 Docker for 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}

关于windows - 在 Docker(适用于 Windows)中,如何在构建镜像时批量添加注册表项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46274898/

相关文章:

windows - 如何在后台从命令行启动 GUI 应用程序?

c++ - 64 位架构 - 从函数返回时字符指针被截断

Python:比较 2 个文本文件的最快方法?

c++ - 如何将退出代码从 Ada 进程返回到调用 Windows 进程?

卷中的 Docker 自定义用户 ID 权限(已安装和未安装)

delphi - 尝试在标准用户上写入 HKLM 时如何不触发异常?

logging - 将 docker-compose 与 GELF 日志驱动程序一起使用

docker - 'DEBIAN_FRONTEND=noninteractive' 无法使用 apt-get 在 shell 脚本内工作

c# - 如何让应用程序名称显示在打开方式列表中?

c - 从注册表启动程序与从启动文件夹启动的区别