Docker and Asterisk

Let’s get straight to the goods, then we’ll examine my methodology.

You can clone or fork my docker-asterisk project on GitHub. And/or you can pull the image from dockerhub.

Which is as simple as running:

docker pull dougbtv/asterisk

Let’s inspect the important files in the clone

.
|-- Dockerfile
|-- extensions.conf
|-- iax.conf
|-- modules.conf
`-- tools
    |-- asterisk-cli.sh
    |-- clean.sh
    `-- run.sh

In the root dir:

In the tools/ dir are some utilities I find myself using over and over:

That’s about it, for now!


There’s a couple key steps to getting Asterisk and Docker playing together nicely, and I have a few requirements:

On the first bullet point, we’ll get over this by using nsenter, which requires root or sudo privileges, but, will let you connect to the CLI, which is what I’m after. I was inspired to use this solution from this article on the docker blog. And I got my method of running it from coderwall.

On the second point… Docker doesn’t like UDP it seems (which is what the VoIP world runs on). At least in my tests trying to get some IAX2 VoIP over it, on port 4569. (It’s an easier test to mock up than SIP!) (Correction: Actually, Docker is fine with UDP, you just have to let it know when you run a docker container, e.g. docker run -p 4569:4569/udp -t user/tag)

So, I settled on opening up the network to Docker using the --net host parameter on a docker run.

At first, I tried out bridged networking. And maybe not all is lost. Here’s the basics on bridging here @ redhat I followed. Make sure you have bridge-utils package: yum install -y bridge-utils. But, I didn’t have mileage with it. Somehow I set it up, and it borked my docker images from even getting on the net. I should maybe read the Docker advanced networking docs in more detail. Aaaargh.

Some things I have yet to do are:

I’m thinking I’ll running xinetd in it’s own container and connect the asterisk image with the xinetd image for running FastAGI.