Docker Community Forums

Share and learn in the Docker community.

Not able to understand how to communicate Docker container with SIP server residing in host layer


My HOST server and PBX Server are on the same LAN. Host server pings SIP server and vice versa.
My application which was on host server is moved to docker container now…
Now, am not able to make a connection from docker container application to the PBX sip server.

This is because the request generated from Docker container application contains the IP of the Docker container and not of the host server. We can port forward to the host layer but IP cannot change… SIP server is not able to ping the docker container

What can be the solution…

(Gary Forghetti) #2

Sounds like you are not publishing the application’s listening port when you start the application’s container so the port is not available outside of Docker and the Application Docker container.
Check here for details ->


Port is exposed properly from the container, issue is with the IP …
i am exposing the port in my container and also forwarding the port to host as well. But the problem is with the IP… the SIP connection which i need is peer to peer . the SIP request packet which is forwarded from container to its host to the PBX SIP server contains the IP of the container and not the IP of the host. We cannot tamper the SIP request packet… So when PBX SIP server recieves the request and wants to ping back , it cannot understand the IP of the container and no communication here…

(Gary Forghetti) #4

Okay. Is it possible for you to start the application docker container with host networking --network host?

1 Like

Yeah little naive here … can you share some examples where i can use the host network while connection… I did some example but could not understand what type of driver should i use when i create the docker network … will it be “overlay” or something else which we can communicate with the Host IP address rather and Host network devices.,
would really appreciate if you share some good content or examples …
Will try out those and will keep posted on my updates…

(Gary Forghetti) #6

Sounds like you are using Docker Swarm. You did not elaborate.
Here’s an example with a Swarm docker-compose file Version 3.6 of running an Apache web server which is listening on port 80 in a docker container with host networking. No need to publish the port.

root@manager:~# cat docker-compose.yml
version: '3.6'

     external: true
     name: "host"

    image: httpd:latest
      - hostnet
root@manager:~# docker stack deploy apache -c docker-compose.yml
Creating service apache_web
root@manager:~# curl
<html><body><h1>It works!</h1></body></html>
root@manager:~# hostname -I

I’m able to access the apache web server port from another host by the IP address of the docker node

🐳  gforghetti:[~] $ curl
<html><body><h1>It works!</h1></body></html>
🐳  gforghetti:[~] $
1 Like

Thanks so much for directing me to the correct usage of docker network. I am able to solve my issue by creating a “macvlan” driver for my docker network. I needed to give the Gateway of my host unix shell and by this way …my docker container can ping back any device which is on the HOST lan and ping is vice versa. The most important thing to take care is Allowing the Promiscuous mode on the host machine.