I am trying to make a few docker containers to hold some of my everyday tooling. But a lot of my tools depend on being able to connect to devices (via wifi) to pull data.
I have been doing research and am rather confused trying to understand what, if anything, would need to be done to support this scenario. I know usually docker containers are the server not the client. But i have read about people doing the opposite.
I am trying to figure out what kind of changes/configuration would be needed to do this.
By default, Docker will create a virtual network on your physical server; e.g. the
docker0
interface. That happens inbridge
mode, it allows this interface to connect to the internet through youreth0
device.eth0
is the physical system interface; everything related to your local as well as global network will pass through theeth0
physical interface.If you want to access the internet or your local network inside your running docker container, you have to add
nameserver
as per your physical system/etc/resolv.conf
file during startup of the docker daemon. This way, everything you can normally access with your physical system you'll be able to access with the docker container.One more thing, you have to expose ports when you start up your docker container so that it can pull data from outside the docker network with the help of the
eth0
interface. All this configuration is automatically taken care with the help ofiptables
. Docker will addsiptables rules
to forward traffic fromdocker0
toeth0
and your service will work perfectly.Example
In the above case, my application is pulling data from
$host_name
via port1522
.-p 1522:1522
means it will send request to port1522
on the physical machine, similarly, the physical machine will send this request to the network hosted machine on the same1522
port."