Issues in running Asterisk in a docker: no sound in calls

I am trying to setup a local instance of Asterisk with an IVR Menu behind a Docker. I am very new to Asterisk so thanks a lot in advance.

Here’s the situation:

The server is in a dockerized instance.
The docker is in a machine that has a local IP 192.168.0.101.

  • If I make a call from the same machine (192.168.0.101/localhost) it works fine.
  • If I make a call from a phone that is in the same LAN (192.168.0.42), I have no sound (but the server logs tell me the call has arrived)
  • But if I install Asterisk on the machine instead of inside the Docker, it works!

So I guess this is network issue. Like those ones:

From those posts, I have tried in sip.conf to set:

[general]
externip=192.168.0.101
localnet=192.168.2.0/255.255.0.0

[tel](my-codecs)
nat=yes

Without success.

I also tried to play with codecs but since it works with the same config on a different network situation, I don’t think this is the issue.

And I checked all online resources of people using Asterisk behind a docker, looking for a specific config, but I haven’t found anything.

Any idea? How does the nat=yes config + externip works?


Extra Data:

Here are the open ports:

    - "8088:8088"
    - "5060:5060/udp"
    - "16384:16384/udp"
    - "16385:16385/udp"
    - "16386:16386/udp"
    - "16387:16387/udp"
    - "16388:16388/udp"
    - "16389:16389/udp"
    - "16390:16390/udp"
    - "16391:16391/udp"
    - "16392:16392/udp"
    - "16393:16393/udp"

With rtp.conf:

[general]
rtpstart=16384
rtpend=16394

sip.conf:

[general]
language=fr
externip=192.168.0.101
localnet=192.168.2.0/255.255.0.0
context=public
allowguest=no
allowoverlap=no
udpbindaddr=0.0.0.0
tcpenable=no
transport=udp
srvlookup=yes

[my-own-codecs](!)
disallow=all
allow=gsm
allow=alaw
allow=ulaw

[ordi](my-own-codecs)
type=friend
context=from-internal
host=dynamic
secret=ordi
nat=yes

[tel](my-own-codecs)
type=friend
context=from-internal
host=dynamic
secret=tel
nat=yes

And here are the logs when I call from the phone:

    -- Executing [100@from-internal:1] Goto("SIP/tel-00000000", "demo-menu,s,1") in new stack
    -- Goto (demo-menu,s,1)
    -- Executing [s@demo-menu:1] Answer("SIP/tel-00000000", "500") in new stack
    -- Executing [s@demo-menu:2] Playback("SIP/tel-00000000", "hello,skip") in new stack
    -- <SIP/tel-00000000> Playing 'hello.gsm' (language 'fr')
    -- Executing [s@demo-menu:3] BackGround("SIP/tel-00000000", "press-1&or&press-2&or&press-3&or&press-4") in new stack
    -- <SIP/tel-00000000> Playing 'press-1.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-2.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-3.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-4.gsm' (language 'fr')
    -- Executing [s@demo-menu:4] WaitExten("SIP/tel-00000000", "5") in new stack
[Dec  5 10:06:43] NOTICE[48]: chan_sip.c:27554 handle_request_subscribe: Received SIP subscribe for peer without mailbox: tel
    -- Timeout on SIP/tel-00000000, going to 't'
    -- Executing [t@demo-menu:1] Playback("SIP/tel-00000000", "are-you-still-there") in new stack
    -- <SIP/tel-00000000> Playing 'are-you-still-there.gsm' (language 'fr')
    -- Executing [t@demo-menu:2] Goto("SIP/tel-00000000", "s,loop") in new stack
    -- Goto (demo-menu,s,3)
    -- Executing [s@demo-menu:3] BackGround("SIP/tel-00000000", "press-1&or&press-2&or&press-3&or&press-4") in new stack
    -- <SIP/tel-00000000> Playing 'press-1.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-2.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-3.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-4.gsm' (language 'fr')
    -- Executing [s@demo-menu:4] WaitExten("SIP/tel-00000000", "5") in new stack
    -- Timeout on SIP/tel-00000000, going to 't'
    -- Executing [t@demo-menu:1] Playback("SIP/tel-00000000", "are-you-still-there") in new stack
    -- <SIP/tel-00000000> Playing 'are-you-still-there.gsm' (language 'fr')
    -- Executing [t@demo-menu:2] Goto("SIP/tel-00000000", "s,loop") in new stack
    -- Goto (demo-menu,s,3)
    -- Executing [s@demo-menu:3] BackGround("SIP/tel-00000000", "press-1&or&press-2&or&press-3&or&press-4") in new stack
    -- <SIP/tel-00000000> Playing 'press-1.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-2.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-3.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'or.gsm' (language 'fr')
    -- <SIP/tel-00000000> Playing 'press-4.gsm' (language 'fr')
[Dec  5 10:07:05] WARNING[48]: chan_sip.c:4047 retrans_pkt: Retransmission timeout reached on transmission Au4nMhTp0cPhi4C163DimUwCJSzaH1OM for seqno 14435 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 31998ms with no response
[Dec  5 10:07:05] WARNING[48]: chan_sip.c:4076 retrans_pkt: Hanging up call Au4nMhTp0cPhi4C163DimUwCJSzaH1OM - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
  == Spawn extension (demo-menu, s, 3) exited non-zero on 'SIP/tel-00000000'

While with the localhost phone:

 == Using SIP RTP CoS mark 5
   -- Executing [100@from-internal:1] Goto("SIP/ordi-00000002", "demo-menu,s,1") in new stack
   -- Goto (demo-menu,s,1)
   -- Executing [s@demo-menu:1] Answer("SIP/ordi-00000002", "500") in new stack
   -- Executing [s@demo-menu:2] Playback("SIP/ordi-00000002", "hello,skip") in new stack
   -- <SIP/ordi-00000002> Playing 'hello.alaw' (language 'fr')
   -- Executing [s@demo-menu:3] BackGround("SIP/ordi-00000002", "press-1&or&press-2&or&press-3&or&press-4") in new stack
   -- <SIP/ordi-00000002> Playing 'press-1.alaw' (language 'fr')
   -- <SIP/ordi-00000002> Playing 'or.alaw' (language 'fr')
   -- <SIP/ordi-00000002> Playing 'press-2.alaw' (language 'fr')
   -- <SIP/ordi-00000002> Playing 'or.alaw' (language 'fr')
   -- <SIP/ordi-00000002> Playing 'press-3.alaw' (language 'fr')
   -- <SIP/ordi-00000002> Playing 'or.alaw' (language 'fr')
   -- <SIP/ordi-00000002> Playing 'press-4.alaw' (language 'fr')
   -- Executing [s@demo-menu:4] WaitExten("SIP/ordi-00000002", "5") in new stack
 == Spawn extension (demo-menu, s, 4) exited non-zero on 'SIP/ordi-00000002'

Maybe @dougbtv could help?

Thanks!

Hi @augnustin – if you want, go ahead and open up an issue on my
docker-asterisk project on github and I can take a look when I get a
chance. But… Instead of opening up all the ports – try in your docker
run command docker run --net=host dougbtv/asterisk (plus whatever other
options minus the ports), if it works then that will let you know it’s some
issue with the ports used, or maybe how it picks up the address to sets the
c= address in the sip sdp payload, e.g. media_address in asterisk’s
sip.conf (and maybe pjsip.conf?) iirc.