How to Setup FreePBX using Docker (Build FreePBX Docker Container)

How to Setup FreePBX using Docker (Build FreePBX Docker Container). In this post, we will introduce FreePBX, it’s features, major advantages. After that we will move onto the FreePBX installation phase with Docker.

First of all what is a PBX or Private Branch Exchange? A telephone hardware system available within a business that allows call switching between users on local phone lines whilst enabling them to share a fixed number of external lines.

So let’s start with our article How to Setup FreePBX using Docker (Build FreePBX Docker Container).

What is FreePBX?

Firstly PBX is an acronym for Private Branch Exchange. FreePBX is basically a phone system that you can install on your virtual machine. It plays an important role in managing asterisk. What is asterisk? Simply put a communication server and is open sourced. Instead of using their own phone system and interface and paying an optimum 100 dollars a month, users can use FreePBX to manage their PBX.

Moreover FreePBX works as a medium of communication between the customers and the office. What it does, it greets the customers in a warm manner to make them feel comfortable and then directs the call to the desired branch or section of the office depending on the customers’ query.

Asterisk allows us to convert an ordinary computer to a communication server using . It is a software implementation of a telephone private branch exchange (PBX), allowing connected telephones to call each other and then connect to other telephone services such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services.

Users can download FreePBX for free but need to have the skillset and the knowledge to set it up and maintain it. You will require an ISTP (Internet Telephony Service Provider) to make calls through FreePBX.

In simple words, Asterisk is a multiple line system allowing communication inside offices within branches through different extensions. Existence of internal extensions lead to sharing of outgoing lines for communication with users or employees inside or outside the office space.

Features of FreePBX

Here are some features of the FreePBX:

  • The system can be back up or restore by the user.
  • You can create IVR (Interactive Digital Receptionist) menus.
  • View call detail reporting with asterisk stat.
  • Allows users to view the trunk status and extension.
  • The ARI (Asterisk Recording Interface) allows the user to view the recordings of the conversations.
  • Additionally allows users to upload custom on hold music. (MOH)
  • Equally FreePBX comes packed with a lot of other features such as: Business Features, Calling Features and Telephony Support.
  • Calling features include: call recording, call transfers, call waiting, blacklisting of callers, call history, voicemail to email, three way calling support.
  • Whereas the telephony support features are: desktop support, speciality device support, WebRTC, POTS/ISDN, SIP and PJSIP.
  • Importantly FreePBX system can fill in as an extra employee, if the need arises. This is one of the most important benefits of using FreePBX. Developed over time to keep in mind the needs and developments.

Advantages of FreePBX

FreePBX has numerous advantages, some of them are listed below:

Vast language support

This advantage of FreePBX allows users to pick their local language on a one to one basis. Further it enables the users to keep their phone system up irrespective of the location of the users across the globe.

Fully equipped WebGUI

Features like WebGUI presents multiple calibrated features like extension development, IVRs, restore and backup, user permissions, time conditions and firewall.

Vast list of unique features

Add on features like high availability and call centre bundles are also provided alongside a 25 year license. That maintains credibility and reliability for business development.

Low Cost

Cost of FreePBX have an edge over expensive and other difficult to use solutions. So reliable FreePBXs can recover the cost in no time.

No limitations on licensing

There is no specific limit as to number of users, IVRs to be built, queues etc.


Flexibility of FreePBX works with almost all the commercially available virtual machines and hardware. Additionally it also works with more than 200 endpoints because of its wide usage across the globe. Can be paired with any IP phone or conferencing solution that you already own.

Reliable and secure

Due to its in house testing and checks, the quality of security is top notch. It goes through rigorous testing process before being rolled out to the general public. What is more it also gets regular updates to improve the stability of the system.

Automatic response system

FreePBX has an automatic response solution through which the user can be directed and forwarded to a specific branch by just pressing a number.

Advancement in technology

With time, a huge advancement in the technology by the means of various updates, can be seen. This allows the users to personalise the system better according to their needs.

Now it is time for the main part of the article about How to Setup FreePBX using Docker .

How to Setup FreePBX using Docker


  • A root user or a user with sudo privileges.

Add Docker Repository

By default, the latest version of Docker is not included in the Ubuntu default repo. So you will need to add the Docker CE official repository to the APT.

First, install all the required dependencies using the following command:

					apt install apt-transport-https ca-certificates curl software-properties-common -y

After installing all the dependencies, download and add the Docker CE GPG key with the following command:

					curl -fsSL | apt-key add -

Next, add the Docker CE repository with the following command:

					add-apt-repository "deb [arch=amd64] focal stable"

Here please verify the Added repository with the following command:

					apt-cache policy docker-ce

You will get the following output:

  Installed: (none)
  Candidate: 5:20.10.17~3-0~ubuntu-focal
  Version table:
     5:20.10.17~3-0~ubuntu-focal 500
        500 focal/stable amd64 Packages
     5:20.10.16~3-0~ubuntu-focal 500
        500 focal/stable amd64 Packages
     5:20.10.15~3-0~ubuntu-focal 500
        500 focal/stable amd64 Packages
     5:20.10.14~3-0~ubuntu-focal 500
        500 focal/stable amd64 Packages
     5:20.10.13~3-0~ubuntu-focal 500
        500 focal/stable amd64 Packages
     5:20.10.12~3-0~ubuntu-focal 500
        500 focal/stable amd64 Packages


Install Docker and Docker Compose

Now, install the Docker package by running the following command:

					apt install docker-ce -y

Once the Docker is installed, verify the Docker running status using the following command:

					systemctl status docker

You will get the following output:

					● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-09-04 16:04:27 UTC; 13s ago
TriggeredBy: ● docker.socket
   Main PID: 3264 (dockerd)
      Tasks: 7
     Memory: 29.8M
     CGroup: /system.slice/docker.service
             └─3264 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.555173170Z" level=warning msg="Your kernel does not support CPU realtime >
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.555196177Z" level=warning msg="Your kernel does not support cgroup blkio >
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.555270124Z" level=warning msg="Your kernel does not support cgroup blkio >
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.555772301Z" level=info msg="Loading containers: start."
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.719676988Z" level=info msg="Default bridge (docker0) is assigned with an >
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.804973724Z" level=info msg="Loading containers: done."
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.834543443Z" level=info msg="Docker daemon" commit=a89b842 graphdriver(s)=>
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.834895532Z" level=info msg="Daemon has completed initialization"
Sep 04 16:04:27 ubuntu2004 systemd[1]: Started Docker Application Container Engine.
Sep 04 16:04:27 ubuntu2004 dockerd[3264]: time="2022-09-04T16:04:27.878373838Z" level=info msg="API listen on /run/docker.sock"


Following step is to verify the Docker version information with the following command:

					docker --version

You should get the following output:

					Docker version 20.10.17, build 100c701

Now please install the Docker Compose package with the following command:

					apt install docker-compose -y

Once the installation is complete, verify the Docker Compose version using the following command:

					docker-compose --version

You should get the following output:

					docker-compose version 1.25.0, build unknown

Create a Docker Compose File for FreePBX

Firstly, create a directory to store the Docker Compose file:

					mkdir app

Next, navigate to the created directory and create a Docker Compose file for FreePBX:

					cd app
nano docker-compose.yaml

Add the following code:

					version: '2'

    container_name: freepbx-app
    image: tiredofit/freepbx
     #### 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/udp
      - 5160:5160/udp
      - 18000-18100:18000-18100/udp
     #### Flash Operator Panel
      - 4445:4445
      - ./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

      - VIRTUAL_NETWORK=nginx-proxy
     ### If you want to connect to the SSL Enabled Container 
     #- VIRTUAL_PORT=443
     #- VIRTUAL_PROTO=https
      - VIRTUAL_PORT=80

      - ZABBIX_HOSTNAME=freepbx-app

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

     ### 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
      - proxy-tier

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

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

    container_name: freepbx-db-backup
    image: tiredofit/db-backup
     - freepbx-db
      - ./dbbackup:/backup
      - 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
      - MD5=TRUE
      - proxy-tier
    restart: always

      name: nginx-proxy


Save and close the file then create a Docker network for Nginx proxy:

					docker network create nginx-proxy

Launch the FreePBX Container

At this point, Docker Compose file is ready to launch the FreePBX container. You can run the following command to launch the FreePBX container:

					docker-compose up -d

This command will download all required images and create a container from each image:

					Pulling freepbx-db (tiredofit/mariadb:)...
latest: Pulling from tiredofit/mariadb
59bf1c3509f3: Pull complete
e887546d6053: Pull complete
3dace326c0ec: Pull complete
ea97c706ca03: Pull complete
f908583427a3: Pull complete
Digest: sha256:9a2b1332bc6b0775765d8ae43e94646d4f5b97d2c5af4d246ab82042241f1517
Status: Downloaded newer image for tiredofit/mariadb:latest
Pulling freepbx-db-backup (tiredofit/db-backup:)...
latest: Pulling from tiredofit/db-backup
213ec9aee27d: Pull complete
0a34d2f2b45d: Pull complete
4dd70801aef3: Pull complete
f471a1502016: Pull complete
bdd9d308f2cc: Pull complete
Digest: sha256:0a49053ee9164087696bf646a453de194debb652bb654e4452c75efa4b1c6661
Status: Downloaded newer image for tiredofit/db-backup:latest
Creating freepbx-db  ... done
Creating freepbx-app       ... done
Creating freepbx-db-backup ... done


You can verify the all downloaded images using the following command:

					docker images

You should get the following output:

					REPOSITORY            TAG       IMAGE ID       CREATED         SIZE
tiredofit/db-backup   latest    fbb26eb96e30   2 weeks ago     521MB
tiredofit/mariadb     latest    158d51d45d6f   6 months ago    420MB
tiredofit/freepbx     latest    e98ede842e6d   17 months ago   2.05GB

Next, verify all running containers using the following command:

					docker ps


You should see the following output:

					CONTAINER ID   IMAGE                 COMMAND   CREATED          STATUS          PORTS                                       NAMES
bb06e45b3ddd   tiredofit/db-backup   "/init"   37 seconds ago   Up 37 seconds   2020/tcp, 10050/tcp      freepbx-db-backup
e7d8d9dbd2d1   tiredofit/freepbx     "/init"   39 seconds ago   Up 33 seconds   80/tcp, 443/tcp, 4569/tcp,>5060/udp, :::5060->5060/udp, 5061/tcp, 5161/tcp, 8001/tcp, 8003/tcp, 8008-8009/tcp, 8025/tcp,>5160/udp, :::5160->5160/udp, 10050/tcp,>4445/tcp, :::4445->4445/tcp,>18000-18100/udp, :::18000-18100->18000-18100/udp, 18101-20000/udp   freepbx-app
c60189d931bf   tiredofit/mariadb     "/init"   39 seconds ago   Up 37 seconds   2020/tcp, 3306/tcp, 10050 tcp freepbx-db 

Access FreePBX Dashboard

1. Now, open your web browser and access the FreePBX container using the URL http://your-server-ip/admin/config.php. You should see the admin password setup screen:

2. Define your admin username, password and click on the Setup System button. You should see the following screen:

3. Click on the FreePBX Administration. You should see the FreePBX login screen:

4. Provide your admin username, password and click on the Continue button. You should see the FreePBX language selection page:

5. Click on the Submit button. You should see the FreePBX dashboard on the following screen:

Thank you for reading How to Setup FreePBX using Docker. We shall conclude. 

How to Setup FreePBX using Docker (Build FreePBX Docker Container) Conclusion

In this post, we explained how to build and run FreePBX using the Docker and Docker Compose. You can now host your own telephone system in your organizations. Summarizing FreePBX makes it easier for us by providing with pre programmed features available through a user friendly web interface that allows us to have a fully functional PBX almost instantly with no programming required.

Please check out our FreePBX content here.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x