BetterVoice / freeswitch-container

This project can be used to deploy a FreeSWITCH server inside a Docker container. The container currently uses the latest stable release version 1.6.x. An effort was made to build many modules so the container can be generic enough to serve many purposes.
https://www.bettervoice.com
238 stars 128 forks source link

FreeSWITCH Dockerfile

Docker Stars Docker Pulls Docker Automated build

This project can be used to deploy a FreeSWITCH server inside a Docker container. The container currently uses the latest stable release version 1.6.x. An effort was made to build many modules so the container can be generic enough to serve many purposes.

The container now includes fail2ban but in order for fail2ban to update the rules in IPTables it must be run with the --privileged flag.

The container exposes the following ports:

Running the Container

CID=$(sudo docker run --name freeswitch -p 5060:5060/tcp -p 5060:5060/udp -p 5080:5080/tcp -p 5080:5080/udp -p 8021:8021/tcp -p 7443:7443/tcp -p 60535-65535:60535-65535/udp -v /home/ubuntu/freeswitch/conf:/usr/local/freeswitch/conf bettervoice/freeswitch-container:1.6.6)

Keep in mind that freeswitch has to be able to read the mounted volume.

Large port range issue

Because of an issue in docker, mapping a large port range like in -p 60535-65535:60535-65535/udp can eat a lot of memory. Starting docker with --userland-proxy=false solves this partially, but startup will still be slow. As a workaround you can remove this from the docker commandline and manually add the iptables rules instead:

CIP=$(sudo docker inspect --format='{{.NetworkSettings.IPAddress}}' $CID)

sudo iptables -A DOCKER -t nat -p udp -m udp ! -i docker0 --dport 60535:65535 -j DNAT --to-destination $CIP:60535-65535
sudo iptables -A DOCKER -p udp -m udp -d $CIP/32 ! -i docker0 -o docker0 --dport 60535:65535 -j ACCEPT
sudo iptables -A POSTROUTING -t nat -p udp -m udp -s $CIP/32 -d $CIP/32 --dport 60535:65535 -j MASQUERADE

Systemd configuration

Follow the following steps in order to run start this docker instance via systemctl.

Customizations For customizing the startup settings look at the wiki documentation in GitHub which deals with running docker as a service in systemd.

sudo cp sysv/systemd/docker.freeswitch.service /lib/systemd/system/
sudo systemctl daemon-reload
sudo cp sysv/docker.freeswitch.py /usr/local/bin/

# Enable the service
sudo systemctl enable docker.freeswitch
# Start the service
sudo systemctl start docker.freeswitch
# Stop the service
sudo systemctl stop docker.freeswitch

Configuration

Make sure you properly set rtp-start-port and rtp-end-port in autoload_configs/switch.conf.xml. Also you need to set ext-rtp-ip and ext-sip-ip for every profile which is accessible from your public ip address. See the freeswitch documentation for further instructions.

Shell access

sudo docker exec -it freeswitch /bin/bash

Available Modules

The following modules are available in the container and can be loaded at runtime by providing a modules.conf.xml file with the desired module names uncommented.

Applications

Speech Recognition / Text-to-Speech

Codecs

Dialplan

Directories

Endpoints

Event Handlers

File Formats

Languages

Loggers

Language-Specific

External API's