DEV Community

loading...

Docker | Which network is your container running under?

idawnwon
So proud to be a coder
・1 min read

I use docker-composer created 4 containers:

  • phpmyadmin
  • wordpress
  • mariadb
  • worker to simulate a cluster.

The worker container should publish read/edit WordPress posts through REST api, so the first thing I have to know is the IP address of wordpress.

docker inspect --format='{{json .NetworkSettings.Networks}}' wordpress
Enter fullscreen mode Exit fullscreen mode

got this:
{"test4_default":{"IPAMConfig":null,"Links":null,"Aliases":["wordpress","3c643dafbb8a"],"NetworkID":"5a0f08a9dda9e1649a50568c697753c8b04277cf4fff73450aeef90bbceab2b4","EndpointID":"6513b7a1cc85f59bac846e979dd2226057654667c27cfeec0fffad505caa5bb7","Gateway":"192.168.80.1","IPAddress":"192.168.80.5","IPPrefixLen":20,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:c0:a8:50:05","DriverOpts":null}}

docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' wordpress
Enter fullscreen mode Exit fullscreen mode

got the ip:
192.168.80.5

Hope this helps!
So proud to be a coder!

Discussion (0)