microsoft / iis-docker

Dockerfile for IIS
https://hub.docker.com/r/microsoft/iis/
MIT License
288 stars 128 forks source link

APPCMD failed with error code 4312 #161

Closed StasClick closed 4 years ago

StasClick commented 4 years ago

I have a docker file with some variables and CMD instruction. It do not work. Simplified example below.

Docker file:

FROM mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 ENV MY_SUPER_VARIABLE="Hello world!" ENTRYPOINT ["C:\ServiceMonitor.exe", "w3svc"] CMD ["C:\ServiceMonitor.exe", "w3svc"]

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

StasClick commented 4 years ago

Interesting to note, if I simply remove line ENV MY_SUPER_VARIABLE="Hello world!" it will work. I cannot understand it.

bariscaglar commented 4 years ago

You don't need to define the entrypoint. IIS image already defines it. See the example on the first page.

StasClick commented 4 years ago

@bariscaglar, yeah, I did it just for testing. But without this line result is the same.

bariscaglar commented 4 years ago

Did you also remove CMD?

StasClick commented 4 years ago

I need CMD. No matter what I put here. It is not work. For example:

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

Simply removing ENV solves the issue. But I need both instructions.

StasClick commented 4 years ago

Hi. I found why it is not working. The CMD command instead of executing "powershell.exe" it extends argument list of ENTRYPOINT. That's why it stop to work.

So the question is, why CMD do not execute executable file in exec form?

kejvi-doko commented 4 years ago

@StasClick I am having the same issue, even when using the docker file coming with https://github.com/microsoft/dotnet-framework-docker.git. Did you have any success finding a solution?

StasClick commented 4 years ago

@kejvi-doko Hi. Yes, solved. But already not remember how. I guess it was related to some windows updates, and when I downloaded new image version, the issue disappeared.

BrunoJuchli commented 2 years ago

In my case the error was fixed by using RUN instead of CMD