Introduction
- I am developing a proprietary application that uses
libevent
withlibevhtp
to create a server socket for http communication. - I wrote a
Dockerfile
to place this application in a docker image.
The resulting docker image, that starts the application per default, runs fine on other computers that I have tested (ubuntu 20.04/22.04) by running the image via
docker run --rm -p 8080:8080 -t mytag
- I can connect to port 8080 of that computer just fine from within the same network.
- I can
docker exec -ti runningcontainer bash
of the running container andnetstat -pntl
to see the application is listening on port 8080.
The Issue
On my laptop this isn't the case. I'm not running Ubuntu like the other servers I have tried it on. I'm on Manjaro. I can't see how that would matter though.
- Inside the running docker container on my laptop with the running application,
netstat -pntl
shows no listening socket - It follows that I can't connect to port 8080 of the application -
curl localhost:8080
returnsConnection Refused
- Running the application on my computer natively (not in docker) works as expected, I can access port 8080
- Running
nc -l 0.0.0.0 9999
inside my docker container that is running on my laptop opens a socket andnetstat
reports it listening. - The connection via
nc 127.0.0.1 9999
from inside the container to that open socket works as expected. - I have tried running the container with
--privileged
with the same result - not working - I have pruned all docker images, containers, networks, uninstalled and removed all traces of docker from my computer and reinstalled it without any change in behavior
Conclusion
It seems to me that the application is not opening any listening sockets when running inside the docker container for some reason. The logs of the implementation show no errors - Note: I have not checked the implementation for errors or some overlooked error code.
I need help figuring out how I could try to debug this the most efficient way.
My next steps would be to
- Create a small binary with libevhtp that serves a test.html file and try running that in docker - and if that works fine
- Slowly disabling parts of the malfunctioning application bit by bit until I can find the culprit.
The second step would be a lot of work so I'm reaching out here in case anyone has had a similar issue or could point to some things I could try before taking on this endeavor.