OpenSIPs Dev Tips: add extra modules to your opensips docker image
The problem: you are missing a module
Let's say you add the db_mysql module to your opensips.cfg file:
loadmodule "db_mysql.so"
And you go to run check your opensips config via docker (like you learned here):
docker run -v ${PWD}/:/etc/opensips --entrypoint /usr/sbin/opensips opensips/opensips:latest -C -f /etc/opensips/opensips.cfg
And you get this error:
CRITICAL:core:yyerror: parse error in /etc/opensips/opensips.cfg:75:13-14: failed to load module db_mysql.so
That means the opensip-mysql-module
package is not installed in your container.
Solution
Rebuild opensips docker image with your module
If you never build the image locally (but pulled the image directly from dockerhub), you will need to do that now.
git clone https://github.com/OpenSIPS/docker-opensips.git
cd docker-opensips
Now add the modules you need in the OPENSIPS_EXTRA_MODULES
environment variable.
OPENSIPS_EXTRA_MODULES="opensips-mysql-module" make build
This will rebuild the image opensips/opensips:latest
with that module installed. Run it again and opensips will stop complaining about them missing module.
Extra tip: verify the [module].so files installed
If you want to verifty the
Warning
Most of the module packages are formatted opensips-[MODULE NAME]-module
, but some are not that straightforward. For example, the mi_http.so
module is under the package opensips-http-modules
. Note the http
without the "mi", and the plural modules
. If you are having trouble finding the module package, go here: https://apt.opensips.org/browse.php. Navigate to your images distro and download the package file and search through it to find the most likely candidate.
Subscribe to my newsletter
Read articles from Brandon directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by