Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a Docker container's IP address, located within a bridge network, from a windows host?

Tags:

docker

mysql

A bridge network has been created in docker using the following:

docker network create blognetwork

And a container has been created in that network with the following:

docker run --name=blogdb --network=blognetwork -p 3306:3306 -e --bind-address=0.0.0.0 -e=MYSQL_ROOT_PASSWORD=mypassword -detach mysql

How do I access the ip address of the new container, within the "blognetwork", from a windows host?

How do I get the ip address of the form X.X.X.X, on its own? I know I can use the following to get a large json output with this data in it:

docker network inspect blognetwork
like image 741
Basil Avatar asked Dec 02 '22 11:12

Basil


1 Answers

You can get directly the ip by using docker inspect and a proper format:

docker inspect containerId --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'

More info in the Docker documentation.

like image 182
juanlumn Avatar answered Dec 20 '22 14:12

juanlumn