I want to set up freepbx / asterix via Docker

Hey,

As a total noob, I have just started and I hope this is the right place to ask a question about docker. Now I want to run a FreePBX docker container which also has Fail2Ban.

I came across hub.docker.com/r/tiredofit/freepbx which offers this possibility.

What I’ve done

I went to https://github.com/tiredofit/docker-freepbx and cloned the project.

Then I changed the docker-compose.yml to this.

    version: '2'

services:
  freepbx-app:
    container_name: freepbx-app
    image: tiredofit/freepbx
    ports:
     #### If you aren't using a reverse proxy
     #- 80:80
     #### If you want SSL Support and not using a reverse proxy
     #- 443:443
      - 5060:5060
      - 5160:5160
      - 18000-18100:18000-18100/udp
     #### Flash Operator Panel
      - 4445:4445
    volumes:
      - ./certs:/certs
      - ./data:/data
      - ./logs:/var/log
      - ./data/www:/var/www/html
     ### Only Enable this option below if you set DB_EMBEDDED=TRUE
     #- ./db:/var/lib/mysql
     ### You can drop custom files overtop of the image if you have made modifications to modules/css/whatever - Use with care
     #- ./assets/custom:/assets/custom

    environment: 
      - VIRTUAL_HOST=voip.XXnl
      - VIRTUAL_NETWORK=nginx-proxy
     ### If you want to connect to the SSL Enabled Container 
     #- VIRTUAL_PORT=443
     #- VIRTUAL_PROTO=https
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=voip.XX.nl
      - LETSENCRYPT_EMAIL=daan@XX-it.nl

      - ZABBIX_HOSTNAME=freepbx-app

      - RTP_START=18000
      - RTP_FINISH=18100
    
     ## Use for External MySQL Server
      - DB_EMBEDDED=FALSE

     ### These are only necessary if DB_EMBEDDED=FALSE
      - DB_HOST=freepbx-db
      - DB_PORT=3306
      - DB_NAME=asterisk
      - DB_USER=asterisk
      - DB_PASS=asteriskpass
    
     ### If you are using TLS Support for Apache to listen on 443 in the container drop them in /certs and set these:
     #- TLS_CERT=cert.pem
     #- TLS_KEY=key.pem
     
    restart: always
    networks:
      - proxy-tier

    ### These final lines are for Fail2ban. If you don't want, comment and also add ENABLE_FAIL2BAN=FALSE to your environment
    cap_add:
      - NET_ADMIN
    privileged: true

  freepbx-db:
    container_name: freepbx-db
    image: tiredofit/mariadb
    restart: always
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=asterisk
      - MYSQL_USER=asterisk
      - MYSQL_PASSWORD=asteriskpass
    networks:
      - proxy-tier

  freepbx-db-backup:
    container_name: freepbx-db-backup
    image: tiredofit/db-backup
    links:
     - freepbx-db
    volumes:
      - ./dbbackup:/backup
    environment:
      - ZABBIX_HOSTNAME=freepbx-db-backup
      - DB_HOST=freepbx-db
      - DB_TYPE=mariadb
      - DB_NAME=asterisk
      - DB_USER=asterisk
      - DB_PASS=asteriskpass
      - DB_DUMP_FREQ=1440
      - DB_DUMP_BEGIN=0000
      - DB_CLEANUP_TIME=8640
      - COMPRESSION=BZ
      - MD5=TRUE
    networks:
      - proxy-tier
    restart: always

networks:
  proxy-tier:
    external:
      name: nginx-proxy

Then I went to the folder and ran docker-compose up -d
What I did do wrong :sweat_smile:

You didn’t tell us what didn’t work but from looking at your docker-compose.yml file, I see that the original has:

environment: 
      - VIRTUAL_HOST=hostname.example.com
...
      - LETSENCRYPT_HOST=hostname.example.com

Where the host name hostname.example.com matches for both lines but your file has:

    environment: 
      - VIRTUAL_HOST=voip.XXnl
...
      - LETSENCRYPT_HOST=voip.XX.nl

Where voip.XXnl != voip.XX.nl. Could that be the problem?

~jr

My Apache2 won’t start (when I ssh’ed the container). So I do not get an interface


I will reinstall my VPS and try it with this one

version: '2'

services:
  freepbx-app:
    container_name: freepbx-app
    image: tiredofit/freepbx
    ports:
     #### If you aren't using a reverse proxy
     #- 80:80
     #### If you want SSL Support and not using a reverse proxy
     - 443:443
      - 5060:5060
      - 5160:5160
      - 18000-18100:18000-18100/udp
     #### Flash Operator Panel
      - 4445:4445
    volumes:
      - ./certs:/certs
      - ./data:/data
      - ./logs:/var/log
      - ./data/www:/var/www/html
     ### Only Enable this option below if you set DB_EMBEDDED=TRUE
     #- ./db:/var/lib/mysql
     ### You can drop custom files overtop of the image if you have made modifications to modules/css/whatever - Use with care
     #- ./assets/custom:/assets/custom

    environment: 
      - VIRTUAL_HOST=xx
      - VIRTUAL_NETWORK=nginx-proxy
     ### If you want to connect to the SSL Enabled Container 
     - VIRTUAL_PORT=443
     - VIRTUAL_PROTO=https
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=xx
      - LETSENCRYPT_EMAIL=daan@xx-it.nl

      - ZABBIX_HOSTNAME=freepbx-app

      - RTP_START=18000
      - RTP_FINISH=18100
    
     ## Use for External MySQL Server
      - DB_EMBEDDED=FALSE

     ### These are only necessary if DB_EMBEDDED=FALSE
      - DB_HOST=freepbx-db
      - DB_PORT=3306
      - DB_NAME=asterisk
      - DB_USER=asterisk
      - DB_PASS=asteriskpass
    
     ### If you are using TLS Support for Apache to listen on 443 in the container drop them in /certs and set these:
     #- TLS_CERT=cert.pem
     #- TLS_KEY=key.pem
     
    restart: always
    networks:
      - proxy-tier

    ### These final lines are for Fail2ban. If you don't want, comment and also add ENABLE_FAIL2BAN=FALSE to your environment
    cap_add:
      - NET_ADMIN
    privileged: true

  freepbx-db:
    container_name: freepbx-db
    image: tiredofit/mariadb
    restart: always
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=asterisk
      - MYSQL_USER=asterisk
      - MYSQL_PASSWORD=asteriskpass
    networks:
      - proxy-tier

  freepbx-db-backup:
    container_name: freepbx-db-backup
    image: tiredofit/db-backup
    links:
     - freepbx-db
    volumes:
      - ./dbbackup:/backup
    environment:
      - ZABBIX_HOSTNAME=freepbx-db-backup
      - DB_HOST=freepbx-db
      - DB_TYPE=mariadb
      - DB_NAME=asterisk
      - DB_USER=asterisk
      - DB_PASS=asteriskpass
      - DB_DUMP_FREQ=1440
      - DB_DUMP_BEGIN=0000
      - DB_CLEANUP_TIME=8640
      - COMPRESSION=BZ
      - MD5=TRUE
    networks:
      - proxy-tier
    restart: always

networks:
  proxy-tier:
    external:
      name: nginx-proxy

I have set the DNS records to this server

Sorry, I can’t help you there. That sounds like more of a FreePBX question than a Docker question. You shouldn’t need to ssh into the container to start anything. It claims to be a turnkey system with a web interface for configuring.

I see that you’ve already opened an Issue on GitHub. It seems the one before yours
Getting an error - Starting Apache httpd web server: apache2 failed! is having the same problem. I would follow that GitHub issue.

~jr