Git Product home page Git Product logo

asterisk's Introduction

Asterisk PBX Docker image

REFACTOR! I started massive refactor, considering comments received in the issues and private emails. Thank you all for the feedback! Once ready, This readme will be updated, right away please look to the existing docker tags on hub

The smallest Docker image with Asterisk PBX https://hub.docker.com/r/andrius/asterisk/

This image is based on Alpine Linux image, which is only a 5MB image, and contains Asterisk PBX.

Total size of this image for latest tag (based on Alpine linux) is:

And for debian-stretch-slim-15-current .

Custom UID/GID

By default, Asterisk will run as default user (asterisk) with UID and GID assigned by alpine linux, but it's possible to specify then through environment variables:

  • ASTERISK_UID
  • ASTERISK_GID (note, GID is not supported in debian releases)

Default asterisk user will be re-created with new UID and GID

In given example, ID's of current host user will be used to start, that will fix permissions issues on logs volume:

docker run -ti --rm \
  -e ASTERISK_UID=`id -u` \
  -e ASTERISK_GID=`id -g` \
  -v ${PWD}/logs:/var/log/asterisk \
  andrius/asterisk

Alternative user

It is possible to specifty other than asterisk user to start through environment variable ASTERISK_USER:

docker run -ti --rm -e ASTERISK_USER=root andrius/asterisk

Versions

Based on Alpine linux:

  • docker pull andrius/asterisk:11.6.1 for Asterisk 11.x (stable release), Alpine 2.6
  • docker pull andrius/asterisk:11 for Asterisk 11.x (stable release), Alpine 2.7
  • docker pull andrius/asterisk:14 for Asterisk 14.x, Alpine 3.6
  • docker pull andrius/asterisk:15.2.2 for Asterisk 15.2.2, Alpine 3.7
  • docker pull andrius/asterisk:15 for Asterisk 15.x, Alpine 3.8
  • docker pull andrius/asterisk:latest for Asterisk 15.x, Alpine latest
  • docker pull andrius/asterisk:edge for latest Asterisk 15.x, based on Alpine edge

What's missing

Only base Asterisk packages installed. If you want to add sounds, it's recommended to mount them as volume or data container, however you may install additional packages with apk command:

  • asterisk-alsa - ALSA channel;
  • asterisk-cdr-mysql - MySQL CDR;
  • asterisk-chan-dongle - chan_dongle, to manage calls and SMS through Huawei USB dongle;
  • asterisk-curl - curl integration with Asterisk;
  • asterisk-dahdi - DAHDI channel (ISDN BRI/PRI, FXO and FXS cards integration);
  • asterisk-fax - support faxing
  • asterisk-mobile - Use Bluetooth mobile phones as FXO devices;
  • asterisk-odbc - ODBC support;
  • asterisk-pgsql - PostgreSQL support;
  • asterisk-sounds-en - sounds
  • asterisk-sounds-moh - music on hold;
  • asterisk-speex - Speex codec;
  • asterisk-srtp - SRTP encryption;
  • asterisk-tds - MS SQL support.

Database support

By default, Asterisk PBX store CDR's to the CSV file, but also support databases. Refer Asterisk PBX documentation for ODBC support.

For Postgre SQL include following lines to your Dockerfile:

RUN apk add --update less psqlodbc asterisk-odbc asterisk-pgsql \
&&  rm -rf /var/cache/apk/*

And For MySQL:

For MySQL, mysql-connector-odbc should be downloaded from the official site and compiled

Based on Debian linux:

Debian Jessie:

  • docker pull andrius/asterisk:debian-11.25.3
  • docker pull andrius/asterisk:debian-12.8.2

Debian Stretch:

  • docker pull andrius/asterisk:debian-13-current
  • docker pull andrius/asterisk:debian-14-current
  • docker pull andrius/asterisk:debian-15-current

asterisk's People

Contributors

andrius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asterisk's Issues

Important information for udp traffic

Hi,

this is not really a issue, but I hope that his can save others a lot of time. If you want to use this image for the German Telekom and register/call via UDP (transport udp) use the --net=host option (or network_mode: "host" in Docker Compose) with this image! Otherwise all the AOR checks and routing will fail because Docker changes the source IP for UDP traffic to (172.x.x.x). I hope this saves someone a few weeks of their life ;) Please add it to the documentation or keep this issue open so people can find it.

Best regards

Only port 5060 exposed

I've noticed that only port 5060 is exposed in all of the Dockerfiles. I couldn't see from the README, but is the intention to run each of the images with the --network host docker flag?

I've been trying all week to provide a comprehensive list of ports to EXPOSE using your upstream images, even reducing the port range in rtp.conf to something more manageable but I cannot get it to work. 5060 initiates the session, but I can't get audio. There seems to be lots of undocumented ports that I just gave up in the end.

If it's intended to be used with the host network, is it actually worth removing the EXPOSE line from the Dockerfiles as you can't actually do anything useful with it?

Great effort maintaining this repo BTW. ๐Ÿ‘

add sngrep

Hi andrius

It would be great if you add the installation of sngrep in all the images you maintain. This is a popular tool for SIP debugging.

Thanks in advance

configuration

Andrius,

Cool project you have here. I got the image to work. How do I add sip support? Also, I'm trying to get into bash so I modify sip.conf and extensions.conf. I can't connect via docker exec. Not sure if there's a better way.

Errors starting up the default andrius/asterisk image.

I get the following in the logs after running andrius/asterisk image:
[Sep 30 01:02:36] == Registered application 'MSet'
[Sep 30 01:02:36] == Registered channel type 'Local' (Local Proxy Channel Driver)
[Sep 30 01:02:36] == Manager registered action LocalOptimizeAway
[Sep 30 01:02:36] Asterisk Dynamic Loader Starting:
[Sep 30 01:02:36] WARNING[1]: loader.c:2222 loader_config_init: 'modules.conf' invalid or missing.
[Sep 30 01:02:36] ERROR[1]: asterisk.c:3926 check_init: Module initialization failed. ASTERISK EXITING!
[Sep 30 01:02:36] == Manager unregistered action DBGet
[Sep 30 01:02:36] == Manager unregistered action DBPut
[Sep 30 01:02:36] == Manager unregistered action DBDel
[Sep 30 01:02:36] == Manager unregistered action DBDelTree
Huh? Child handler, but nobody there?

thanks!

Local time

Hi, thanks for excellent project!
Can you please set the local time to UTC in the containers? PST is not very useful in Russia ;)

ARI Playback via URL fails at v18

Hey there,

I'm currently testing Asterisk with ARI and audio playback via URL. I'm using mono WAV files with 16bit PCM and a sampling rate of 8kHz. I started with Asterisk 15 using the andrius/asterisk:15.x Docker image and everything works fine. I updated to andrius/asterisk:17-current and still no issues.

After that I wanted to update to the next LTS using the andrius/asterisk:glibc-18.x image, but with that asterisk refuses to play my file with the following outputs:

asterisk_1   \| [Mar 12 20:38:18] WARNING[106][C-00000001]: file.c:789 ast_openstream_full: File https://example.com/8c22dd75.wav does not exist in any format 
asterisk_1   \| [Mar 12 20:38:18] WARNING[106][C-00000001]: file.c:1262 ast_streamfile: Unable to open https://example.com/8c22dd75.wav (format (alaw)): Invalid argument 
asterisk_1   \| [Mar 12 20:38:18] WARNING[106][C-00000001]: res_stasis_playback.c:276 playback_final_update: 1615581497.0: Playback failed for sound:https://example.com/8c22dd75.wav

I would like to investigate that further and would be very happy for any hint. Thanks!

Support for M1

Hello, trying to spin up the container with commands provided at README.md on macOS with M1 chip.
Here are the results of the actions:

1.) Running . . .

docker run -ti --rm \
  -e ASTERISK_UID=`id -u` \
  -e ASTERISK_GID=`id -g` \
  -v ${PWD}/logs:/var/log/asterisk \
  andrius/asterisk

results in response:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
addgroup: gid '20' in use
  1. Running . . .
docker run -ti --rm -e ASTERISK_USER=root andrius/asterisk

results in response:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
No ethernet interface found for seeding global EID. You will have to set it manually.
Parsing /etc/asterisk/asterisk.conf
*** buffer overflow detected ***: /usr/bin/qemu-x86_64 terminated

Thanks for your time spent on this issue!
Br,
Juraj

I hope the project can add openvpn(or other VPN) to solve the issues of RTP behind Docker Nat

Now I can use IAX only , but SIP should be better. There are some solution to add huge range of UDP forward . It seems too complicate and hard to manage. If the alpine have vpn , it can bypass the NAT and firewall issues. I tried to add openvpn in front of asterisk . It worked perfectly. But I hope this two functions can work in same container. It can reduce the machine loading.

Docker entrypoint.sh is invalid

It seems that running the container with volumes mapped result in an error

/docker-entrypoint.sh: 24: exec: -v: not found

Obsolete asterisk version

So version 15 is definitely not the latest, it has not been for a long time now. Any chance we could get an updated image for 18 or at least 17?

Configuring network.

I am having a hard time using net=host and registering with my provider. Any suggestions?

pjsip appears to work fine in v15

I noticed you remove the pjsip module in your Dockerfile (caused some confusion for me initially doing configuration). I'm using the v15 branch and modified the Dockerfile to not do this -- Asterisk appears to be functioning fine. It would be nice to not have the module deleted.

Also, as an FYI, this image works great on a Raspberry Pi.

get error messages like these:

[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: Failed to resolve dependencies for res_stir_shaken
[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: res_stir_shaken declined to load.
[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: cdr_sqlite3_custom declined to load.
[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: cel_sqlite3_custom declined to load.
[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: Failed to resolve dependencies for res_http_media_cache
[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: res_http_media_cache declined to load.
[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: Failed to resolve dependencies for res_pjsip_stir_shaken
[Jun  7 14:53:39] ERROR[1]: loader.c:2508 load_modules: res_pjsip_stir_shaken declined to load.

mysql-connector-odbc

ERROR: unsatisfiable constraints:
mysql-connector-odbc (missing):
required by: world[mysql-connector-odbc]

Looks like there is no mysql-connector-odbc packet. Is there any solution?

Wrong opus codec version

In this file Dockerfile
asterisk/debian/16-certified/Dockerfile
this line
ENV OPUS_CODEC asterisk-16.0/x86-64/codec_opus-13.0_current-x86_64
should be changed to
ENV OPUS_CODEC asterisk-16.0/x86-64/codec_opus-16.0_current-x86_64

Asterisk crashes on trunk registration on latest version 18.15

Hi,
I've stumbled upon an issue about asterisk crashing when I tried to register a trunk on the latest update (docker hub of 30/11/2023).
The registration message got to the trunk, and it sent an Unauthorized answer. When Asterisk receives the message, it crashes right away.
I've rolled back to the alpine-3.17-18.15.1 version and it works properly.
Might be good to check the 20.5 versions of asterisk.

I've noticed that the GitHub repository has not been updated lately when the image on docker hub has been updated. Is it intentional?

Best Regards,
Simon

Issue on Trunk with CUCM

Hi Andrius, thanks for your wonderful work.
I'm trying to connect an asterisk for development on my laptop and i did a trunk, both side,
with a Cisco Call Manager used in my office.
Trunk works in both side and sip telephone register on asterisk can ring a cisco telephone resiter an CUCM and viceversa.

But when I Answer the call HangUp and in asterisk on my laptop I got this error:

   -- Channel SIP/callmanageriset-00000054 joined 'simple_bridge' basic-bridge <5d8debd7-7b17-4364-9182-26ef7eacadfb>
    -- Channel SIP/pierpa-00000053 joined 'simple_bridge' basic-bridge <5d8debd7-7b17-4364-9182-26ef7eacadfb>
[Feb  7 09:26:41] WARNING[48]: chan_sip.c:4119 retrans_pkt: Retransmission timeout reached on transmission [email protected] for seqno 81 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 6400ms with no response
[Feb  7 09:26:41] WARNING[48]: chan_sip.c:4143 retrans_pkt: Hanging up call [email protected] - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
    -- Channel SIP/pierpa-00000053 left 'simple_bridge' basic-bridge <5d8debd7-7b17-4364-9182-26ef7eacadfb>
    -- Channel SIP/callmanageriset-00000054 left 'simple_bridge' basic-bridge <5d8debd7-7b17-4364-9182-26ef7eacadfb>

sniffing with tcpdump and opening with wireshark i noticed that the called phone try to start rdp session with the asterisk ip inside the docker so thi is probably the resons while it fails.
https://drive.google.com/open?id=1NUcHOt1FDaBl9x1jl7_Zf7iAbRFRPbMA

What i'am missing?
thanks in advance
Pier Paolo

Problem inheriting from image

Writing my own Dockerfile inheriting from andrius/asterisk where I add some files to /var/lib/asterisk/sounds/ I run into the problem that in my parent Dockerfile (andrius/asterisk) the directory is defined as VOLUME
Because of that all the files added by my Dockerfile during build process are gone when starting the container (see https://stackoverflow.com/questions/46227454/modifying-volume-data-inherited-from-parent-image and https://docs.docker.com/engine/reference/builder/#notes-about-specifying-volumes).

I could add the files during container startup (via ENTRYPOINT) but that would mean that on each startup the sound files would have to been downloaded.
Currently I use a copy of your Dockerfile without the VOLUME commands.

Both solutions are workaround/hacks. Do you have an idea how to solve this issue in a clean manner?

Problems using Masterisk-Manger as container in combination with IObroker/Asterisk-Adapter

Hello,
I used to installe asterisk manager as packages within an IOBroker docker container, but since in the latest debian versions, the asterisk manager is now longer included I needed another solution: I installed the asterisk manager as an separate docker container using this andrius-container. I set it up with a portainer docker compose file:
version: '3' services: iobroker: network_mode: "host" restart: always image: buanet/iobroker:latest container_name: iobroker-9 hostname: iobroker-9 ports: - "8081:8081" - "3671:3671" volumes: - /volume1/docker/iobroker-Chrisham:/opt/iobroker - /volume1/docker/userscripts:/opt/userscripts - /volume1/docker/Backup:/opt/backup/ environment: - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - DEBIAN_FRONTEND=teletype - LANG=de_DE.UTF-8 - LANGUAGE=de_DE:de - LC_ALL=de_DE.UTF-8 - SETGID=1000 - SETUID=1000 - TZ=Europe/Berlin - USBDEVICES=/dev/ttyUSB0 - PACKAGES=influxdb2-cli devices: - /dev/ttyUSB0:/dev/ttyUSB0 asterisk: network_mode: "host" restart: always image: chris-andri-asterisk:latest container_name: asterisk-9 ports: - "5038:5038" - "5060:5060" volumes: - /volume1/docker/asterisk/extensions.ael:/etc/asterisk/extensions.ael - /volume1/docker/asterisk/manager.conf:/etc/asterisk/manager.conf - /volume1/docker/asterisk/sip.conf:/etc/asterisk/sip.conf - /volume1/docker/asterisk/sip_fritzbox.conf:/etc/asterisk/sip_fritzbox.conf - /volume1/docker/asterisk/rtp.conf:/etc/asterisk/rtp.conf environment: - PACKAGES=ffmpeg lame sox libsox-fmt-mp3 influxdb: network_mode: "host" restart: always image: influxdb:latest container_name: influxdb-9 ports: - "8086:8086" volumes: - /volume1/docker/influxdb/config:/etc/influxdb2 - /volume1/docker/influxdb/data:/var/lib/influxdb2 environment: - PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - GOSU_VER=1.12but - INFLUXDB_VERSION=2.7.1 - INFLUX_CLI_VERSION=2.7.3 - INFLUX_CONFIGS_PATH=/etc/influxdb2/influx-configs - INFLUXD_INIT_PORT=8086 - INFLUXD_INIT_PING_ATTEMPTS=600 - DOCKER_INFLUXDB_INIT_CLI_CONFIG_NAME=default - DOCKER_INFLUXDB_INIT_MODE=setup - DOCKER_INFLUXDB_INIT_USERNAME=iobroker - DOCKER_INFLUXDB_INIT_PASSWORD=*1Xs(QD5gY0!B&XHe1_x - DOCKER_INFLUXDB_INIT_ORG=smarthome - DOCKER_INFLUXDB_INIT_BUCKET=iobroker grafana: network_mode: "host" restart: always image: grafana/grafana:latest container_name: grafana-9 ports: - "3000:3000" volumes: - /volume1/docker/grafana:/var/lib/grafana - /volume1/docker/grafana:/var/lib/grafana/plugins - /volume1/docker/grafana/views/index.html:/usr/share/grafana/public/views/index.html - /volume1/docker/grafana/conf/defaults.ini:/usr/share/grafana/conf/defaults.ini
The chris-andri-asterisk:latest container image is derived from andrius container:
`# vim:set ft=dockerfile:
FROM alpine:latest

LABEL maintainer="Andrius Kairiukstis [email protected]"

ENV LANG=C.UTF-8
ENV LC_ALL C.UTF-8

RUN set -e
&& apk add --update --quiet
asterisk
asterisk-sample-config >/dev/null
ffmpeg
lame
sox
&& asterisk -U asterisk &>/dev/null
&& sleep 5s
&& [ "$(asterisk -rx "core show channeltypes" | grep PJSIP)" != "" ] && :
|| rm -rf /usr/lib/asterisk/modules/pj
&& pkill -9 ast
&& sleep 1s
&& truncate -s 0
/var/log/asterisk/messages
/var/log/asterisk/queue_log || :
&& mkdir -p /var/spool/asterisk/fax
&& chown -R asterisk: /var/spool/asterisk
&& rm -rf /var/run/asterisk/*
/var/cache/apk/*
/tmp/*
/var/tmp/*

EXPOSE 5038/udp 5038/tcp
VOLUME /var/lib/asterisk/sounds /var/lib/asterisk/keys /var/lib/asterisk/phoneprov /var/spool/asterisk /var/log/asterisk

ADD docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]`

But still I have problems: The Asterisk adapter from IOBroker somehow seems to connect:
asterisk-connected

But then later comes these errors:
asterisk-error

Any ideas what the problem could be?

Thanks

CLI background color

I'm using the Alpine version under UNRAID and I have problems with the color of the text in the CLI.
Some of the text (usually debug messages) is displayed black on dark grey background (see attached screenshot) and therefore barely readable. After such a line is displayed also the color of the commands typed afterwards becomes black on dark grey.
Initially I thought that there is a problem with my specific asterisk configuration, or the TERMINAL settings or the Docker configurations....
After some hair pulling I realized that the culprit is the -W from the asterisk command line from docker-entrypoint.sh

if [ "$1" = "" ]; then
  COMMAND="/usr/sbin/asterisk -T -W -U ${ASTERISK_USER} -p -vvvdddf"
else

-W Display colored terminal text as if the background were white or otherwise light in color. Normally, terminal text is displayed as if the background were black or otherwise dark in color.

Given that normally the linux console has a black background I think that this setting is inconvenient for most of the people.
Could you please change this to -B instead or eventually make it configurable?
Of course, you already provided a nice mechanism to override the entire COMMAND, however maybe some people, just like me, will have difficulties to figure out from where the problem comes in the first place.

Thanks and keep up the good work!
asterisk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.