Running Asterisk and it's mysql database in different docker containers

1.7k views Asked by At

If I have correctly understood the use and purpose of docker, every process should be inside it's own container, thus not interfering with other running processes.

So based on that, I would like to run an Asterisk PBX server in one container, mysql database in other container and in the third container I would like to run the FreePBX GUI for Asterisk.

Running each of those services in it's own container is not a problem, but how would I connect those three together afterwards as I need the mysql db to log calls using CDR variables and the FreePBX should be installed to provide the GUI experience the for Asterisk configuration.

Any advice is appreciated, Thanks.

1

There are 1 answers

0
Max Prokopov On

You should definitely give a try to docker-compose. This tool will help you to expose one container to other in easy way.

Your example with docker-compose.yml could look like this:

db:
   image: mysql:5
   environment:
     - MYSQL_PASSWORD=pass
     - MYSQL_USER=asterisk
     - MYSQL_DATABASE=freepbx

asterisk:
  image: asterisk
  links:
    - db

freepbx:
   image: php5-apache
   links:
     - db
   volumes-from:
     - asterisk

This will create 3 containers, first for DB, second for asterisk itself, third for freepbx. Asterisk and freepbx image will be able to connect to database host. Also freepbx will have access to volumes, which is published inside asterisk, for example, logs to parse, or config files.