Forrest logo
back to the docker tool

docker:tldr:d5f10

docker: Display a container's IP address.
$ docker inspect --format='${range -NetworkSettings-Networks}${-IPAddress}${end}' ${container}
try on your machine

The command "docker inspect --format='${range -NetworkSettings-Networks}${-IPAddress}${end}' ${container}" is used to retrieve the IP address of a Docker container.

Let's break down the command:

  • "docker inspect" is a Docker CLI command that is used to obtain detailed information about Docker objects, including containers.
  • "--format='${range -NetworkSettings-Networks}${-IPAddress}${end}'" specifies the format in which the output of the command should be presented. In this case, it uses a Go template syntax to extract the IP address from the container's network settings.
  • "${container}" is a placeholder for the actual name or ID of the Docker container you want to inspect.

So, when you run this command with the name or ID of a specific Docker container, it will retrieve and display the IP address of that container's network.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool