简体   繁体   English

DockerFile的一些问题

[英]Some issues with DockerFile

Hello I have a problem with setting up a dockerFile. 您好,我在设置dockerFile时遇到问题。 I want to say that I am new under docker. 我想说我是docker下的新手。 here is the docker version 这是Docker版本

C:\>docker version
Client:
Version:      18.03.1-ce
API version:  1.37
Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:12:48 2018
 OS/Arch:      windows/amd64
 Experimental: false
 Orchestrator: swarm`


Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.24)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:21:42 2018
  OS/Arch:      windows/amd64
  Experimental: false

I created a docker image in which I copied an executable. 我创建了一个docker镜像,在其中复制了可执行文件。 I manage to run the .exe in a container by starting it . 我设法通过启动.exe在容器中运行它。 Currently I would like to automate things using a dockerFile. 目前,我想使用dockerFile自动执行操作。 My image is called bt1: version1 it is based on microsoft / windowsservercore. 我的映像称为bt1: version1它基于microsoft / windowsservercore。

Here is my dockerFile in question. 这是我的dockerFile问题。

The goal is to start a container then inside to modify the file test.xml then to launch the application BT_simulator.exe. 目标是启动一个容器,然后在内部修改文件test.xml,然后启动应用程序BT_simulator.exe。

FROM bt1:version1
WORKDIR "/BTsimulatorV1.1/release"
RUN powershell.exe
RUN "$doc = [xml](Get-Content /BTsimulatorV1.1/release/test.xml) 
&& $doc.parameters.connection.port = " " 
&& $doc.parameters.connection.ipAddress = " " 
&& $doc.parameters.Tool_EEPROM.Serial_Number = " " 
&& $doc.save("/BTsimulatorV1.1/release/test.xml") 
&& BT_simulator.exe

I do not have to achieve the expected behavior. 我不必实现预期的行为。 Can you help me please? 你能帮我吗?

The manipulation of the xml file should not be done in the Dockerfile. xml文件的操作不应在Dockerfile中完成。 The Dockerfile runs only once, during image build. 在映像构建期间,Dockerfile仅运行一次。 What you need is an ENTRYPOINT script which will do the file manipulation and start the exe. 您需要一个ENTRYPOINT脚本,它将执行文件操作并启动exe。

Everything from RUN powershell.exe onwards should be deleted. 从RUN powershell.exe开始的所有内容都应删除。 The script should be put into an .ps script and ADDed to the image. 该脚本应放入.ps脚本中,并添加到映像中。 Then call it with ENTRYPOINT. 然后使用ENTRYPOINT进行调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM