invalid IP address: 999.0.0.1 means the first part of a port mapping in your
Compose file is not a valid IP address. Each of the four numbers in an IPv4 address must
be between 0 and 255. Fix the address, for example "127.0.0.1:15900:80".
The message shows the value it could not read and nothing else, so search the
ports: lists of your services for it.
The error
PS> docker compose -f compose.yaml config
invalid IP address: 999.0.0.1
The file:
name: fix10-cy-q6
services:
web:
image: alpine
command: ["sleep", "1"]
ports:
- "999.0.0.1:15900:80"
Why it happens
A mapping with three parts, "IP:HOST:CONTAINER", takes the first part as the
address on the host to bind to. 999 does not fit in one byte, so
999.0.0.1 is not an IPv4 address. config refused it, and
up -d on the same file printed the same single line with exit code 1;
afterwards docker ps -a and docker network ls, filtered on the
project name, listed nothing, so no container or network had been created.
An address typed by hand with one wrong digit is enough to cause it. Since the check
runs on config, you can find it without starting anything: run
docker compose config after every edit of a ports list, and the
bad value is printed back to you before any container exists. The message carries no file
name, no service and no line number, only the address, so with several services in one
file the quoted value is the only thing to search for.
The fix
name: fix10-cy-q6
services:
web:
image: alpine
command: ["sleep", "1"]
ports:
- "127.0.0.1:15900:80"
PS> docker compose -f compose.fixed.yaml config
...
ports:
- mode: ingress
host_ip: 127.0.0.1
target: 80
published: "15900"
protocol: tcp
...
With a real address, config prints the mapping with host_ip:
127.0.0.1, published: "15900" and target: 80, the
three parts of the mapping in their long form.
How it was reproduced
Docker Desktop on Windows 11, Docker Compose v5.7.0, engine 29.9.3, Windows PowerShell
5.1. A one-service compose.yaml with the mapping
"999.0.0.1:15900:80" gave the message above on docker compose -f
compose.yaml config with exit code 1; with 127.0.0.1 the same command
printed the model with exit code 0. No container was started and no port was opened. The
project name fix10-cy-q6 is the test's own.
Frequently asked
- What does invalid IP address mean in docker compose ports?
- The first part of a three-part port mapping is not a valid IP address. In the test 999.0.0.1 was refused, because 999 is above 255.
- How do I set the host IP in a compose port mapping?
- Put it in front of the mapping, as in 127.0.0.1:15900:80. In the test config then showed host_ip: 127.0.0.1.
- Does docker compose config check the port mapping IP?
- Yes. In the test config alone printed invalid IP address: 999.0.0.1 and exited with code 1, before anything was started.
More decoded errors in the Fixes category. A host port out of range in the same mapping gives invalid hostPort.