This project provides an Asterisk 20 LTS Docker image, specifically compiled from source to ensure seamless compatibility across different architectures, including macOS (ARM64) and Linux (AMD64).
It natively integrates advanced and open-source codecs that are usually missing from standard Asterisk packages due to licensing or repository restrictions.
The image supports traditional G.711 codecs alongside specialized codecs designed for bandwidth and performance:
bcg729 open-source library)This container is not just an "empty Linux." It comes pre-installed with the most essential tools required for testing and debugging network or SIP traffic on a PBX server:
sngrep: Terminal-based concurrent SIP traffic analyzer (The most powerful tool for troubleshooting).tcpdump: Network packet analyzer.ping and net-tools (netstat): For connectivity checks.curl: For API and HTTP testing.vim and nano: Built-in editors for quick text and configuration changes inside the container.procps: For process management (top, ps commands).Open your terminal (macOS or Linux), navigate to the directory containing the Dockerfile, and run the following command:
docker build -t asterisk-pbx .
(Note: Because this process compiles Asterisk from source code (C), it may take 5-10 minutes depending on your processor speed.)
Once the image is successfully built, you can start the server in the background (-d detached mode):
docker run -d --name asterisk-server -p 5060:5060/udp asterisk-pbx
By default, SIP traffic over UDP uses port
5060. That is why we map5060:5060/udp. If necessary, you can also map RTP ports (e.g.,10000-10099/udp) by adding-p 10000-10099:10000-10099/udpto the command.
In this project structure, Asterisk's core settings are read from the config/ directory located in your current path.
During the Dockerfile build, all files inside your config/ folder (pjsip.conf, extensions.conf, modules.conf, etc.) are copied into the /etc/asterisk/ directory inside the image.
When you make a configuration change:
config/ directory.docker build -t asterisk-pbx ..docker run ... command.(Alternatively, for testing purposes, you can bind-mount the config/ directory using the -v flag so you don't have to rebuild every time: docker run -d --name asterisk-server -p 5060:5060/udp -v $(pwd)/config:/etc/asterisk asterisk-pbx)
To view real-time Asterisk logs:
docker logs -f asterisk-server
To enter the container and monitor SIP packets second-by-second with sngrep:
docker exec -it asterisk-server sngrep
To securely log into the Asterisk Command Line Interface (CLI):
docker exec -it asterisk-server asterisk -r
(Once inside the CLI, you can check the internal state of Asterisk using commands like pjsip show endpoints, core show codecs, etc.)
Content type
Image
Digest
sha256:3ae17b360…
Size
393.9 MB
Last updated
3 months ago
docker pull imansur/asterisk-pbx