Skip to content

Run container with configs & debug container

doug edited this page May 15, 2016 · 2 revisions

clone the repo

[doug@talos ~]$ cd /tmp/

[doug@talos tmp]$ git clone https://github.com/dougbtv/docker-asterisk.git
Cloning into 'docker-asterisk'...
[...snipped...]

[doug@talos tmp]$ cd docker-asterisk/
[doug@talos docker-asterisk]$ docker pull dougbtv/asterisk

Make these three files

These are just versions of what's found in the /test/ directory, there's a number of configs there.

sip.conf

[general]
alwaysauthreject=yes            ; Makes account scanning void.
allowguest=no                   ; No guests!
context=default                 ; Default context for incoming calls
allowoverlap=no                 ; Disable overlap dialing support. (Default is yes)
udpbindaddr=0.0.0.0             ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
tcpenable=no                    ; Enable server for incoming TCP connections (default is no)
tcpbindaddr=0.0.0.0             ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
transport=udp                   ; Set the default transports.  The order determines the primary default transport.
bindaddr=0.0.0.0

; ---------------------- Connect another endpoint with this username "theuser"
[theuser]
defaultuser=theuser
fromuser=theuser
type=friend
insecure=invite
; ----------------------- Change this line below
host=ANY_IP_OR_HOSTNAME
port=5060
nat=force_rport,comedia
context=inbound
disallow=all
allow=ulaw

rtp.conf

;
; RTP Configuration
;
[general]
rtpstart=10001
rtpend=10001

iax.conf

[general]
bandwidth=low
disallow=lpc10                  ; Icky sound quality...  Mr. Roboto.
jitterbuffer=no
forcejitterbuffer=no
autokill=yes

[theuser]
type=friend
auth=md5
context=insidecaller
trunk=no
secret=makeagoodsecret
defaultuser=theuser
username=theuser
host=dynamic
encryption=yes
requirecalltoken=no
disallow=all
allow=gsm

Running the container

Put those three files in your current working directory and issue:

docker run \
--name asterisk \
-h asterisk \
-p 4569:4569/udp \
-p 5060:5060/udp \
-p 10001:10001/udp \
-v $(pwd)/sip.conf:/etc/asterisk/sip.conf \
-v $(pwd)/rtp.conf:/etc/asterisk/rtp.conf \
-v $(pwd)/iax.conf:/etc/asterisk/iax.conf \
-d -t dougbtv/asterisk

Example of running container, and then entering the container at the asterisk prompt

[doug@talos docker-asterisk]$ docker run \
> --name asterisk \
> -h asterisk \
> -p 5060:5060/udp \
> -p 10001:10001/udp \
> -v $(pwd)/sip.conf:/etc/asterisk/sip.conf \
> -v $(pwd)/rtp.conf:/etc/asterisk/rtp.conf \
> -v $(pwd)/iax.conf:/etc/asterisk/iax.conf \
> -d -t dougbtv/asterisk
bc0ac3e35fbfbf7112b64dfcc462b020127051370fc2381d122822b688b70e14
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                              NAMES
bc0ac3e35fbf        dougbtv/asterisk    "/bin/sh -c 'asterisk"   7 seconds ago       Up 3 seconds        0.0.0.0:5060->5060/udp, 0.0.0.0:10001->10001/udp   asterisk
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ docker exec -it asterisk asterisk -rvvv
Asterisk 11.6-cert11, Copyright (C) 1999 - 2013 Digium, Inc. and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 11.6-cert11 currently running on asterisk (pid = 1)
asterisk*CLI> 
asterisk*CLI> 
asterisk*CLI> sip show pe
peers  peer   
asterisk*CLI> sip show peers
Name/username             Host                                    Dyn Forcerport ACL Port     Status      Description                      
theuser/theuser           (Unspecified)                                N             0        Unmonitored                                  
1 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 1 offline]
asterisk*CLI> 
asterisk*CLI> 
asterisk*CLI> 
asterisk*CLI> iax2 show pe
peer   peers  
asterisk*CLI> iax2 show peers
Name/Username    Host                 Mask             Port          Status      Description                     
theuser/theuser  (null)          (D)  255.255.255.255  0         (E) Unmonitored                                 
1 iax2 peers [0 online, 0 offline, 1 unmonitored]
asterisk*CLI> 
asterisk*CLI> 
asterisk*CLI> quit
Asterisk cleanly ending (0).
Executing last minute cleanups
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ docker stop asterisk && docker rm asterisk

Run container for debug

[doug@talos docker-asterisk]$ docker run -it dougbtv/asterisk /bin/bash
[root@1c0c2a622e2d /]# echo "hello world"
hello world
[root@1c0c2a622e2d /]# ps ax
  PID TTY      STAT   TIME COMMAND
    1 ?        Ss     0:00 /bin/bash
   15 ?        R+     0:00 ps ax
[root@1c0c2a622e2d /]# exit
exit

Debug already running container

[doug@talos docker-asterisk]$ docker run --name asterisk -h asterisk -p 5060:5060/udp -p 10001:10001/udp -v $(pwd)/sip.conf:/etc/asterisk/sip.conf -v $(pwd)/rtp.conf:/etc/asterisk/rtp.conf -v $(pwd)/iax.conf:/etc/asterisk/iax.conf -d -t dougbtv/asterisk
00a500240382cc4b9263b4f7b1fc3a0c8115c848634eec21b3fed3f0b8977b68
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ 
[doug@talos docker-asterisk]$ docker exec -it asterisk /bin/bash
[root@asterisk /]# echo "hello world"
hello world
[root@asterisk /]# exit
exit