0

I have a containerized application composed of many containers. One of the container which resides in internal docker network is responsible to register external services to my application. During the registration this container needs to provide IP address of my application to external service. Hence the external service can then consume some APIs of my application.

Imagine that my application runs on a host having 4 network interfaces but my application is bound to just one of the interfaces. Hence during the registration, I need to provide this interface / IP information to external service.

I have a solution right now. One of the containers reside in host network. And with the code block below I can make a socket connection and gather IP address which I connect from my host to external service:

        try (var socket = new Socket())
        {
            socket.connect(new InetSocketAddress(targetIp, targetPort));
            return socket.getLocalAddress().getHostAddress();
        }

Just for this purpose I need to have one container residing in host network and consuming some memory. I want to get rid of this container and do it in my registration container -reside in internal docker network-.

How can I do it? If possible some pre-processing is also welcome during start up of my application.

This question has difference from similar ones due to fact that I need to gather particular network interface which my container connects to external service through.

2
  • You haven't even said what language you're using. Commented Apr 20, 2024 at 9:18
  • @TobySpeight does it really matter? It's a container running a Spring Boot application. It has one end point which returns the IP adress / network interface of my host where the communication to external services goes through. Commented Apr 20, 2024 at 12:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.