Get the IP address

Modified: 21 Oct 2024 22:57 UTC

There are a number of ways to get your container's IP address. Read below to learn about docker inspect or watch the screencast to see that method and more in action.

You can quickly get your container's IP address is with docker inspect. One way to use docker inspect is with Go templating.

$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' <container name>
165.225.173.195

It is also possible to use grep to get the same information. docker inspect <container name> | grep IPAddress will give you the same results, formatted differently.

$ docker inspect <container name> | grep IPAddress
"IPAddress": "165.225.173.195"

This command will give you the container's IPAddress address. This IP address may be public, meaning it is accessible over the public internet, or private, meaning the IP is only accessible to your other containers. Docker containers on Triton are always assigned a private IP and have public IP addresses if requested by adding -p or -P to docker run.

On Triton, triton ip <container name> will give you the primary IP number, without having to sort through all of the instance details. If you want all of the IPs assigned to your container, use triton instance get <container name>.

For more information about IPs and networking on Triton, read our networking and fabric user guide. Learn about managing DNS for your applications with Triton CNS.

Watch the screencast

Watch to see how you can use three different methods to get the IP address of your Docker container.