Hi ,
I am creating python project using docker .
I could not get real system ip address . i am getting only docker ip address.
Kindly help to resolve this issue to get real system ip address.
Share and learn in the Docker community.
Hi ,
I am creating python project using docker .
I could not get real system ip address . i am getting only docker ip address.
Kindly help to resolve this issue to get real system ip address.
A container will not be able to see the hosts network interface(s) unless it’s running in --network host
mode. When run with --network host
the container will attach to the hosts network namespace and actualy use the very same interfaces your host has.
N.B.: be aware that this weakens the isolation of the container and opens a vector for possible attacks: If such a container is exposed to the internet and exploited + the exploited process inside the container is run as root, an attacker could install tools to sniff traffic from all host interfaces and could access all services reachable by 127.0.0.1.
Update: I missed out that it’s for mac. The --network host
might not work for mac at all or will use the network interface of the vm docker is run in. Docker Desktop always runs the docker engine in a vm, regardless wether it’s for mac, windows or linux…