Access Host machine from Docker


We want to access the host machine port from the docker container, some use cases are you have existing DB in local machine and want to use.


  • open bash inside you docker container
  • run the following command

    ip route show
  • The command will return a result something like below

    default via dev eth0 dev eth0 proto kernel scope link src
  • The eth0 is the ip can be used to interact with host machine
  • To get a IP alone, we can use following IP

    ip route show | awk '/default/ {print $3}'

Published 25 days ago

Developed by Kamalakannan © 2020