IIS Dockerfile: APPCMD failed with error code 4312

Viewed 3901

I have a docker file with some variables and CMD instruction. And it do not work if I'll add CMD and variables. Simplified example below.

Docker file:

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

docker info:

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

Commands:

docker build -t oracle_db .
docker run -it oracle_db

Result:

 Service 'w3svc' has been stopped

APPCMD failed with error code 4312

Failed to update IIS configuration

If I remove ENV or CMD instruction, everything will work fine, but I need both instructions.

1 Answers

The IIS base image already has an entrypoint defined. Your call to CMD is not running powershell during the build, it is adding additional parameters to the existing ENTRYPOINT. If you are trying to run something as part of the build, you need to use RUN and not CMD

Related