Skip to content

Get the IP addresses of Docker containers

How to find the local IP addresses for running Docker containers.

To list all Docker containers and their corresponding IP addresses, run:

List all
docker inspect -f "{{.Name}}: {{.NetworkSettings.IPAddress }}" $(docker ps -aq)

To get the IP address for a specific Docker container, run:

List by container
docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" CONTAINER_ID

To list all Docker Compose containers and their corresponding IP addresses, run:

List all Docker Compose
docker inspect -f "{{.Name}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $(docker ps -aq) | cut -c2-

You can add these to your ~/.profile, ~/.bashrc, or ~/.zshrc in handy aliases like:

Docker: dip or dips
# Get IP addresses of all Docker containers
alias dips='docker inspect -f "{{.Name}}: {{.NetworkSettings.IPAddress }}" $(docker ps -aq)'

# Get IP addess of specific Docker container. Usage: dip CONTAINER_NAME_OR_ID
alias dip='docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}"'
Docker Compose: dcips
# Get IP addresses of all Docker Compose containers
alias dcips='docker inspect -f "{{.Name}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $(docker ps -aq) | cut -c2-'