docker inspect shows an empty IP address for a container
The IP address field is empty for the containerShort answer
A container only has an IP address while it runs and is attached to a bridge-type network. A stopped container has none, the none network gives only a loopback device, and the host network shares the host's own address. Check the state and the network mode first, then read the address from the right network.
Fix it fast
1Find out which cause you have
List the container with its state, then read the full inspect output: the network mode and the Networks section name the cause.
docker ps -a --filter name=<container> docker inspect <container> docker network inspect bridge2Match what you see, then jump to its fix
- 1
The state is exited or created.The container is not runningFix - 2
The network mode is none and the container cannot reach anything.The container was started with --network noneFix - 3
The network mode is host and the address field is empty.The container uses the host networkFix - 4
docker network inspect bridge does not list the container, but docker ps shows it running.The address is on a user-defined network, not on the default oneFix
- 1
What does the error look like?
The IP address field is empty for the containerdocker inspect shows no address for the container
Cause 1 of 4
The container is not running
1Check
Stopped containers lose their IP addresses. The address comes from the network's subnet only while the container is up.
docker ps -a --filter name=<container>2Fix
Start the container, then read its address.
docker start <container>3Verify
The address appears in the inspect output.
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container>Confirmed by docs.docker.com
Cause 2 of 4
The container was started with --network none
1Check
With the none driver only the loopback device exists inside the container, and no other interface.
docker inspect <container> # read the NetworkMode field2Fix
Recreate the container on a bridge network, for example a user-defined one.
docker network create app-net
docker run -d --name web --network app-net nginx3Verify
Read the address from the new network.
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' webConfirmed by docs.docker.com
Cause 3 of 4
The container uses the host network
1Check
With the host driver the container does not get its own IP address, and the application is reachable on the host's address. Options such as -p are ignored.
docker inspect <container> # read the NetworkMode field2Fix
Use the host's address, or recreate the container on a bridge network and publish the ports you need.
docker run -d --name web --network app-net -p 8080:80 nginx3Verify
Request the published port from the host.
curl -I http://localhost:8080Confirmed by docs.docker.com
Cause 4 of 4
The address is on a user-defined network, not on the default one
1Check
Each container gets an address from the subnet of its own network. A container attached to a user-defined network is listed under that network, not under the default bridge.
docker network ls2Fix
Inspect the network the container is attached to.
docker network inspect app-net3Verify
The container appears with its address in the output.
docker network inspect app-netConfirmed by docs.docker.com
How do I stop it coming back?
- Talk to containers by name on a user-defined network instead of by IP address; addresses change when containers restart.
- Do not hard-code container IPs in configuration.
- Write the network mode into your run command or Compose file, so nobody has to guess it later.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fixServers
Cypress says the npm package is installed but the binary is missing
Cypress binary is missing after npm install in CI or in a Docker build
The npm package is only a launcher.
3 causes, each with a fixServers
A dev container port does not open in the browser when Docker runs on a remote host
If your application only accepts calls from localhost, it will reject connections from published ports
Three things usually break it: the app listens only on localhost inside the container, so published ports are rejected; you open the container port instead of the mapped localhost port VS Code shows; or you changed appPort or a Compose ports list and did not rebuild.
3 causes, each with a fix