Docker Community Forums

Share and learn in the Docker community.

Communicate and obtain data from another hosts


(Kbeaskoetxea) #1

Hi everyone,
I am trying to obtain data externally from a container that is running on my PC, but I can’t see very clear how to do it.
The scenario is:
My PC: running a container that consumes data from internet (provided by the java app).
Another PC: running a java app that provides data to internet. (I know that if I put this app into a container it would be quite easy to connect both containers with Docker overlay driver… but that’s not the case)

image

What would be the correct way to share data between the java app and my container?


(David Maze) #2

However you’d solve this particular problem without Docker, it’d be the same. Docker doesn’t make it easier or harder.


(Kbeaskoetxea) #3

Yeah, but I mean, my docker container it’s supposed to share same IP direction as my host, so, is it possible to the container to listen/obtain the info that’s getting my host without specifying any particular configuration? Or, instead, do I have to use a macvlan network driver with the container?


(David Maze) #4

I’m not sure which direction data is flowing.

The problem as you originally described it sounded like, say, you’re doing an apt-get install that pulls data from packages.ubuntu.com. That needs no special configuration at all. The process in your container makes an outbound TCP connection as normal, and returning data gets routed back to your process.

If things are going in the other direction – the remote service is pulling data from your system – then you need the docker run -p option, and to somehow tell the remote system your host’s DNS name and the port you published.

While this forum seems to be quite enamored of macvlan I’ve never ever needed it.