我写了一个docker文件,我希望它在我创建一个新容器时执行命令。当发生这种情况时,它首先在我的服务器上执行,同时创建图像。
用于创建图像的命令
docker build -t myimage:latest .
Docker文件
#FROM microsoft/nanoserver
FROM microsoft/windowsservercore
MAINTAINER test@gmail.com
ADD ["files", "c:/files"]
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
RUN dism /online /Enable-Feature /all /FeatureName:IIS-ISAPIExtensions /NoRestart
RUN dism /online /Enable-Feature /all /FeatureName:IIS-ISAPIFilter /NoRestart
RUN dism /online /Enable-Feature /all /FeatureName:IIS-ASPNET /NoRestart
RUN dism /online /Enable-Feature /all /FeatureName:IIS-CGI /NoRestart
RUN dism /online /Enable-Feature /all /FeatureName:IIS-CGI45 /NoRestart
我缺少什么,以及如何确保命令仅在docker实例化期间运行。
答案 0 :(得分:0)
如果要在创建docker容器时运行命令,则需要将此行添加到Dockerfile
# replace 'python application.py' with whatever you need
CMD python application.py