microsoft / dotnet-framework-docker

The repo for the official docker images for .NET Framework on Windows Server Core.
https://hub.docker.com/_/microsoft-dotnet-framework
MIT License
692 stars 332 forks source link

aspnet:4.8-windowsservercore-ltsc2022 won't start with port binding #1111

Closed chadmyers closed 3 months ago

chadmyers commented 3 months ago

Describe the Bug

When running with a port binding (8080 -> 80 on container port), the container immediately fails with error:

Stopping service 'w3svc'

Service 'w3svc' has been stopped 

APPCMD failed with error code 4312

Failed to update IIS configuration

Steps to Reproduce

docker run mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2022 -p 8080:80

Other Information

I'm running this on a Windows 11 laptop with Docker Desktop 4.27.1 (136059). It consistently happens every time I try it.

If I leave off -p 8080:80, it doesn't die immediately but then it gets a random port.

Also, curiously, if I attempt to pass in any environment variable (i.e. --env FOO=bar) it'll give me the same error.

Output of docker version

Client:
 Version:           25.0.2
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        29cf629
 Built:             Thu Feb  1 00:24:09 2024
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.27.1 (136059)
 Engine:
  Version:          25.0.2
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.6
  Git commit:       fce6e0c
  Built:            Thu Feb  1 00:23:01 2024
  OS/Arch:          windows/amd64
  Experimental:     false

Output of docker info

❯ docker info
Client:
 Version:    25.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1-desktop.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.3-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  debug: Get a shell into any image or container. (Docker Inc.)
    Version:  0.0.22
    Path:     C:\Program Files\Docker\cli-plugins\docker-debug.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.21
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-feedback.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.0.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.3.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 4
  Running: 0
  Paused: 0
  Stopped: 4
 Images: 57
 Server Version: 25.0.2
 Storage Driver: windowsfilter
  Windows:
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics internal l2bridge l2tunnel nat null overlay private transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local splunk syslog
 Swarm: inactive
 Default Isolation: hyperv
 Kernel Version: 10.0 22631 (22621.1.amd64fre.ni_release.220506-1250)
 Operating System: Microsoft Windows Version 23H2 (OS Build 22631.3235)
 OSType: windows
 Architecture: x86_64
 CPUs: 20
 Total Memory: 63.68GiB
 Name: DESKTOP-URR9GDI
 ID: d9b3968f-569e-4c55-a914-9cae0e4480b7
 Docker Root Dir: C:\ProgramData\Docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
chadmyers commented 3 months ago

UPDATE: OK, this is because I was using docker run wrong. You must pass the image name last. Any arguments after the image name are passed into the entrypoint which was tripping up whatever the base image was doing with cmd-line parameters.

The error message could be more helpful, but I don't consider this a bug with the container image, this was me using docker wrong. Closing. Hopefully this will help others who encounter the same problem.