I want to get docker host machine ip address and interface names i.e ifconfig of docker host machine. instead im getting docker container ip address on doing ifconfig in docker container.
It would be great if someone tell me to fetch ip address of docker host machine from a docker container.
i have tried doing ifconfig dockerhostname, as a result i get error dockerhostmachi: error fetching interface information: Device not found
This is my dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y \ python-dev \ libffi-dev \ libssl-dev \ python-enum \ apache2 \ libapache2-mod-wsgi \ python-pip \ python-qt4
RUN chmod -R 777 /var/log/apache2/error.log
RUN chmod -R 777 /var/log/apache2/other_vhosts_access.log
RUN chmod -R 777 /var/log/apache2/access.log
RUN chmod -R 777 /var/run/apache2/
RUN a2enmod wsgi
i need to get ifconfig result for docker host machine from a docker container or when i run docker image.
The answer to above question is follows .
$ sudo docker network create --driver=bridge --subnet=192.168.10.0/24 --gateway=192.168.10.1 doc1net
or
$ sudo docker network create --driver=bridge --subnet=10.45.0.0/24 --gateway=10.45.0.0 doc1net
Here sub-net and gateway can be your own network address and doc1net is a my network name.
2 METHOD
While running the docker connect with your network host.
$ sudo docker network ls
gives you list of your networks.
$ sudo docker run -it --network=host myimage
Here myimage is name of the image i have created
2nd method worked for me.