VoIP with Asterisk on Synology via Docker

Having successfully banished our need for a physical phone from upstairs, everything changed. My Raspberry Pi is being repurposed for a family member and I now have a Synology DiskStation.

Thus I needed to find a way to run Asterisk on my Network Array Storage (NAS) device. Asterisk provides Voice Over IP (VoIP) and it needs an always on computer to work. Previously my Raspberry Pi performed that role, now my DiskStation must take its place.

I knew that Docker would be part of the eventual solution but I was surprised by how long it has taken to find workable images and settings.

What follows are my notes for getting this working.

Docker Image and Synology Settings

Synology provide a Docker package through the Package Center. Using this edition of Docker, I settled upon the following image by Andrius Kairiukstis:

andrius/alpine-asterisk:14
The alpine-asterisk Docker image.
The alpine-asterisk Docker image.

Launch this image with the following settings:

  • Advanced Settings > Enable auto-restart
  • Advanced Settings > Network > Use the same network as Docker Host

The setting Use the same network as Docker Host is important. This allows Asterisk to open ports and communicate without restriction. Ideally it would not be required but Synology’s Docker web interface is limited. The required port range options are not yet exposed.

Host network setting in Launch settings.
Host network setting in Launch settings.

By applying Use the same network as Docker Host there is no need to specify port mapping or exposing ranges. The container is free to open ports and chatter away. This does go against the contained nature of Docker but for this situation it bypasses many problems.

Alpine Linux and Asterisk

Next set up Asterisk. Create a terminal session to the running Docker container. Do this by Secure Shell (ssh) into the Synology and connect to the Asterisk container using:

sudo docker exec -it asterisk-alpine sh

The container is named asterisk-alpine in this example and sh is the command to execute.

Issue these commands to add any desired extras to Asterisk:

apk update
apk search -v 'asterisk*'
apk add asterisk-sounds-en

I did not immediately need any extra files but any use of the talking clock or answer machines will.

Repeat the configuration of the Raspberry Pi to set up lines and connect to the GrandStream HT-503 box.

Once set up, the asterisk-alpine container consumed 24 MB of RAM and less than 1% CPU, and requires 33 MB of storage.