Skip to content
Docker Engine

Container IPs

Licobox lets you reach a container directly through its internal IP address, so you can test a service without publishing a host port and without port clutter.

Terminal window
licobox install-helper
Terminal window
docker inspect nginx --format '{{.NetworkSettings.IPAddress}}'
  1. Install and start licobox-helper.
  2. Run a container. The example uses nginx.
  3. Read the container’s internal IP.
  4. Request the container directly with curl.
Terminal window
# Install the helper
licobox install-helper
# Run a container
docker run --rm --name nginx -d nginx
# Read the container's internal IP
docker inspect nginx --format '{{.NetworkSettings.IPAddress}}'
# 172.17.0.2
# Request the container directly
curl -I 172.17.0.2

A working request returns something like:

HTTP/1.1 200 OK
Server: nginx/1.29.7
Content-Type: text/html
Content-Length: 896
TaskCommand
Install the helperlicobox install-helper
Run a test containerdocker run --rm --name nginx -d nginx
Get one container’s IPdocker inspect nginx --format '{{.NetworkSettings.IPAddress}}'
Request by IPcurl -I 172.17.0.2
The IP is empty

The container may not be running, or it may use a Compose network with a different address. Inspect the network settings to see every attached network:

Terminal window
docker inspect nginx --format '{{json .NetworkSettings.Networks}}'
Connection refused when requesting the IP

The service may listen on a different port or only on localhost inside the container. Check the port it binds to, and add the port to the request:

Terminal window
curl -I 172.17.0.2:8080
The IP changes after a restart

That is expected. Docker assigns a new IP when a container is recreated. Use Container names for a stable address, or keep the container running.