2

我有一个带有一些变量和 CMD 指令的 docker 文件。如果我添加 CMD 和变量,它就不起作用。下面的简化示例。

码头工人文件:

FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019
ENV MY_SUPER_VARIABLE="Hello world!"
CMD ["powershell", "echo", "Hello!"]

码头信息:

Client:
Debug Mode: false

Server:
Containers: 46
Running: 0
Paused: 0
Stopped: 46
Images: 65
Server Version: 19.03.2
Storage Driver: windowsfilter
Windows:
Logging Driver: json-file
Plugins:
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 17763 (17763.1.amd64fre.rs5_release.180914-1434)
Operating System: Windows Server 2019 Standard Evaluation Version 1809 (OS Build 17763.615)
OSType: windows
Architecture: x86_64
CPUs: 2
Total Memory: 7.906GiB
Name: WIN-P1U2Q5DO49C
ID: 4BOF:LAK4:XOTP:2FNA:3OBR:YDIU:LFWW:3MZ3:N6R4:ZIAC:QK3X:VDSX
Docker Root Dir: C:\ProgramData\Docker
Debug Mode: true
File Descriptors: -1
Goroutines: 41
System Time: 2019-10-01T05:15:37.0250428-07:00
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

命令:

docker build -t oracle_db .
docker run -it oracle_db

结果:

 Service 'w3svc' has been stopped

APPCMD failed with error code 4312

Failed to update IIS configuration

如果我删除 ENV 或 CMD 指令,一切都会正常工作,但我需要两个指令。

4

1 回答 1

2

IIS 基础映像已经定义了一个入口点。您的调用CMD在构建期间没有运行 powershell,它正在向现有的ENTRYPOINT. 如果您尝试在构建过程中运行某些内容,则需要使用RUN而不是CMD

于 2021-09-10T10:55:58.107 回答