One-click deployment of sip service Kamailio

Step 1: Create a Docker Compose file

First, a Docker Compose file needs to be created to configure the Kamailio container, MySQL container, and RTPproxy container. A file called docker-compose.yml can be created with the following command:

sudo nano docker-compose.yml

Then, add the following to the file:

​
version: '3'
services:
  kamailio:
    image: kamailio/kamailio
    ports:
      - "5060:5060/udp"
    restart: always
    depends_on:
      - rtpengine
    environment:
      RTPENGINE_PROXY_IP: rtpengine
      RTPENGINE_RECODE_IP: rtpengine
      RTPENGINE_RECORDING_NODE_PORT: 22222
    volumes:
      - ./kamailio:/etc/kamailio
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: your_password_here
      MYSQL_DATABASE: kamailio
    volumes:
      - ./mysql:/var/lib/mysql
    restart: always
  rtpengine:
    image: rtpproxy/rtpproxy
    network_mode: host
    restart: always
    privileged: true
    command: "-u root -l <host-ip>:7722 -s udp:0.0.0.0:7722 -b 0.0.0.0 -F"

​

This Docker Compose file will start three containers: the Kamailio container, the MySQL container, and the RTPproxy container. The Kamailio container will use RTPproxy for media stream relay, the MySQL container will use mounted volumes to store data locally in the ./mysql directory, and the RTPproxy container will run on port 7722 on the host and route all RTP streams to the Kamailio container.

Note that it is very important to set RTPENGINE_PROXY_IP and RTPENGINE_RECODE_IP in the environment variables. These variables should be set to the IP address or hostname where the RTPproxy container is running and the two containers should be able to communicate with each other.

Step 2: Start the container

Now that the Docker Compose file is ready, the Kamailio, MySQL and RTPproxy containers can be started with the following commands:

sudo docker-compose up -d

This command will start three containers and run them in the background.

Step 3: Test the container

Now that the Kamailio, MySQL, and RTPproxy containers have been successfully started, use a SIP client software such as Zoiper to verify that Kamailio is working properly and is streaming the RTP stream correctly. The container logs can be viewed with the following command:

sudo docker-compose logs kamailio

The log output will show that the Kamailio container is listening for SIP requests and responding when received. At the same time, the RTPproxy container will start accepting and processing all RTP requests with the Kamailio container.

That's it for a complete Kamailio, MySQL and RTPproxy container deployment with steps and documentation.

Guess you like

Origin blog.csdn.net/huapeng_guo/article/details/130109359