Unable to create a python socket listener inside a container

I’ve created a docker image that runs a ROS1 rospy project. This project is run on a mobile robot that connects to the onboard computer running the image container. In order to communicate properly, the container needs to open a socket listener that binds to an ip. The ip in question is the gateway ip of the tag (the onboard computer). The issue is that for whatever reason the socket creation fails when running inside the container, but not when running natively.

heres the line in question :

self.socket_listener = SocketListener(MOBILE_BASE_CONFIGS[“omron_tag_gateway_ip”],

I’ve tried running both with docker compose and with docker run and in both case it wont work.

The container and the exterior are able to communicate since it is able to connect to the tag ethernet ip and communicate to the robot base, but it simply wont open a socket listener.

The specific error is Erno99 - cannot assign requested address.

I can show dockerfile, compose file and docker run command if needed. Thanks in advance.

Are you really using Docker Desktop? What IP are you trying to bind to? IP addresses on your host will not work inside the container unless you run the container on host network, which will not work with Docker Desktop as you have a virtual machine too and the host network is the network of the VM.

No i dont use docker desktop, I might have created the issue in the wrong place. And I run my container with network=host so yes they should be able to communicate. The issue has more to do with the socket creation, since I already know the host is able to communicate with the container. thx

I moved the topic to a better category then.

Since the error message is

I still think this is about the IP address even though it should work with the host network. Try to run this command:

docker run --rm -it --network host nicolaka/netshoot ip a

Do you see the IP address in the list?

You can also run this:

docker run --rm -it python:3-alpine python -m http.server --bind "$IP_ADDRESS" 8080

Replace "$IP_ADDRESS"with the actual IP. If it works too, you convinced me that the problem is not the IP.

I cannot test right now, but I will get back to you when I have access to the robot