Container Port Mapping Issue

I am encountering a port mapping issue when running SQL Server 2025 container with Docker. After the container starts, the port mapping displays incorrectly, preventing me from connecting to the SQL Server instance over the network.​

Environment Information​

  • Docker Desktop version: latest
  • Operating System: Windows 11 Pro
  • SQL Server image: mcr.microsoft.com/mssql/server:2025-latest or mcr.microsoft.com/mssql/server:2022-latest

Reproduction Steps

  1. Pull SQL Server 2025 image

    docker pull mcr.microsoft.com/mssql/server:2025-latest
    
  2. Create and run SQL Server container

    docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sqlserver -d mcr.microsoft.com/mssql/server:2025-latest
    

Issue

When container is not running: in Docker Desktop’s containers page, the ports column correctly shows 1433:1433​

After container starts:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9b52f30b0025 Microsoft Artifact Registry “/opt/mssql/bin/laun…” 6 minutes ago Up 6 minutes 1433/tcp sqlserver​

Docker Desktop’s ports column becomes empty.

Running docker ps command, the PORTS column shows 1433/tcp instead of the expected 0.0.0.0:1433->1433/tcp

Docker inspect results:

"PortBindings": {
    "1433/tcp": [
        {
            "HostIp": "",
            "HostPort": "1433"
        }
    ]
},
"Ports": {
    "1433/tcp": null
}

Expected Behavior

I expect the port mapping to show 0.0.0.0:1433->1433/tcp, allowing me to connect to the SQL Server instance via localhost:1433 or 127.0.0.1:1433.

Troubleshooting attempts

  1. Stopped and restarted the container
  2. Deleted and recreated the container
  3. Checked if port 1433 is occupied on the host (confirmed it’s not)
  4. Tried different port mappings (e.g., -p 1434:1433), issue persists
  5. Restarted Docker service
  6. Reinstall Docker

Network configuration check

  1. Container network mode: bridge (default)
  2. Cannot connect to SQL Server through port 1433

Additional Information

  1. Container logs show SQL Server starts normally
  2. Firewall is configured to allow traffic on port 1433
  3. Other containers is normal

Supplement:

exec docker network inspect bridge

[
    {
        "Name": "bridge",
        "Id": "3824b3449e381553bc97e49a458f93cc4d2b636be59bc90010ed827a516cb664",
        "Created": "2025-10-17T12:09:36.959047771Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv4": true,
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "9b52f30b0025563994e308e88c46f5b36a45ff625bbc770c94159f93eefb853d": {
                "Name": "sqlserver",
                "EndpointID": "e33ebe754cfd927c85338ef5fdb9e45f2cb5122c61ada03df1b348b4d4446677",
                "MacAddress": "b2:3e:f6:53:44:96",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]

Has anyone encountered a similar issue, or knows how to resolve this port mapping problem? Any help would be greatly appreciated!

Could be that sql server inside the container’s only listening on 127.0.0.1 instead of 0.0.0.0. It should make the port mapping disappear even when docker says it’s exposed.

Your output doesn’t look right. It almost looks like the output for .HostConfig.PortBindings is not from the same container as .NetworkSettings.Ports. While the first is indeed what you see when a port is published, the second is what you see when a host is set to EXPOSE in the Dockerfile, but no port is published for this container port..

This is how both values look if they are from the same container:

with port mapping

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sqlserver -d mcr.microsoft.com/mssql/server:2025-latest
docker inspect --format '{{json .HostConfig.PortBindings}}' sqlserver
docker inspect --format '{{json .NetworkSettings.Ports}}' sqlserver
docker rm -f sqlserver

output:

PS C:\Users\metin> docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sqlserver -d mcr.microsoft.com/mssql/server:2025-latest
fe2a280c4e1f63ec406c41649f41a0fd9c5f322bfb307d4300b913c79c6a75a9
PS C:\Users\metin> docker inspect --format '{{json .HostConfig.PortBindings}}' sqlserver
{"1433/tcp":[{"HostIp":"","HostPort":"1433"}]}
PS C:\Users\metin> docker inspect --format '{{json .NetworkSettings.Ports}}' sqlserver
{"1433/tcp":[{"HostIp":"0.0.0.0","HostPort":"1433"},{"HostIp":"::","HostPort":"1433"}]}
PS C:\Users\metin> docker rm -f sqlserver
sqlserver

without portmapping

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -v sqlvolume:/var/opt/mssql --name sqlserver -d mcr.microsoft.com/mssql/server:2025-latest
docker inspect --format '{{json .NetworkSettings.Ports}}' sqlserver
docker inspect --format '{{json .HostConfig.PortBindings}}' sqlserver
docker rm -f sqlserver

output:

PS C:\Users\metin> docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -v sqlvolume:/var/opt/mssql --name sqlserver -d mcr.microsoft.com/mssql/server:2025-latest
8508a0301a28f005393401424fc6a7a2935437b27326cd31041f1ac9695699cd
PS C:\Users\metin> docker inspect --format '{{json .HostConfig.PortBindings}}' sqlserver
{}
PS C:\Users\metin> docker inspect --format '{{json .NetworkSettings.Ports}}' sqlserver
{"1433/tcp":null}
PS C:\Users\metin> docker rm -f sqlserver
sqlserver

Tested on Docker Desktop 4.48.0.

This can be easily tested with docker run -it --net container:sqlserver nicolaka/netshoot netstat -tln. The process inside the mssql contaier binds to 0.0.0.0:1433 and :::1433.

they are from the same container and test sql server inside the container’s

PS C:\Users\17233> docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sqlserver -d mcr.microsoft.com/mssql/server:2025-latest
87a0dea6af6ff28c9736cd3ed0fb45bfb9ff0d9c953f9a352372690473dd512f
PS C:\Users\17233> docker inspect --format '{{json .HostConfig.PortBindings}}' sqlserver
{"1433/tcp":[{"HostIp":"","HostPort":"1433"}]}
PS C:\Users\17233> docker inspect --format '{{json .NetworkSettings.Ports}}' sqlserver
{"1433/tcp":[]}
PS C:\Users\17233> docker run -it --net container:sqlserver nicolaka/netshoot netstat -tln
Unable to find image 'nicolaka/netshoot:latest' locally
latest: Pulling from nicolaka/netshoot
b71379f7ad56: Pull complete
777b2eb9c233: Pull complete
8a84d69553b4: Pull complete
60a997354055: Pull complete
6825d4104fcf: Pull complete
9739e82eeb67: Pull complete
e3d67c957395: Pull complete
44718f283b64: Pull complete
4fe72e03ed63: Pull complete
1ffbfc3fee40: Pull complete
f97746911927: Pull complete
4f4fb700ef54: Pull complete
c48e6ef5a450: Pull complete
b402f437fea1: Pull complete
fe07684b16b8: Pull complete
Digest: sha256:7f08c4aff13ff61a35d30e30c5c1ea8396eac6ab4ce19fd02d5a4b3b5d0d09a2
Status: Downloaded newer image for nicolaka/netshoot:latest
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:135             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:1433            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:1431          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:1434          0.0.0.0:*               LISTEN
tcp        0      0 :::135                  :::*                    LISTEN
tcp        0      0 :::1433                 :::*                    LISTEN
tcp        0      0 ::1:1434                :::*                    LISTEN
tcp        0      0 ::1:1431                :::*                    LISTEN

@thenickward Please take a look too

Thank you for sharing the output!

The output of .NetworkSettings.Ports looks like if the port mapping configuration went missing somewhere.
Are you using the latest Docker Desktop for Windows version as well?

I would suggest raising an issue in the GitHub project that tracks Docker Desktop for Windows issues:

Can you try, if it makes a difference if a user defined bridge is used?

docker network create sqlserver
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sqlserver -d --network sqlserver mcr.microsoft.com/mssql/server:2025-latest

Thanks for the reply, the problem still exists after testing.

PS C:\Users\17233> docker network create sqlserver
b511854d85e74d3183955039e3c0370b013c5450e5141b75f711a2bd98f2f2b7
PS C:\Users\17233> docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=123456!Sa" -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sqlserver -d --network sqlserver mcr.microsoft.com/mssql/server:2025-latest
5ebbe578bee337092ec76056811eb083a43cfdf8d686cb06ae4bd9da53019cfe
PS C:\Users\17233> docker inspect --format '{{json .HostConfig.PortBindings}}' sqlserver
{"1433/tcp":[{"HostIp":"","HostPort":"1433"}]}
PS C:\Users\17233> docker inspect --format '{{json .NetworkSettings.Ports}}' sqlserver
{"1433/tcp":[]}
PS C:\Users\17233> docker run -it --net container:sqlserver nicolaka/netshoot netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:135             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:1433            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.11:40419        0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:1431          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:1434          0.0.0.0:*               LISTEN
tcp        0      0 :::135                  :::*                    LISTEN
tcp        0      0 ::1:1431                :::*                    LISTEN
tcp        0      0 ::1:1434                :::*                    LISTEN
tcp        0      0 :::1433                 :::*                    LISTEN

I’m also going to GitHub to submit this issue.

I leave it here for other users to find it more easily.

Can you check Windows “excluded port ranges.”
Windows can reserve ports even when nothing is listening, which silently blocks Docker’s bind.

Run below commands in PowerShell :

netsh interface ipv4 show excludedportrange protocol=tcp
netsh interface ipv6 show excludedportrange protocol=tcp

If you see 1433 within any range, try a different host port (e.g., -p 51433:1433) or free the range (corporate policies may prevent that). Then re-run the container and confirm docker ps shows 0.0.0.0:51433->1433/tcp.

3 Likes

Thanks, it has solved my question!

Since this issue has no obvious error characteristics, it is highly recommended that Docker automatically detects the port exclusion range of the host machine when running a container, and prompts the user to change the port if it falls within this range.

Could you please share that idea in the GitHub issue you created or in the roadmap? Since you closed the issue, the roadmap would be a better place probably.

You shared the link to this topic but I would not expect developers clicking on that link soon if any time in a closed issue.