├── Dockerfile ├── README.md └── turnserver.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM phusion/baseimage:0.9.18 2 | MAINTAINER Brian Prodoehl 3 | 4 | # Set correct environment variables. 5 | ENV HOME /root 6 | 7 | # Use baseimage-docker's init system. 8 | CMD ["/sbin/my_init"] 9 | 10 | RUN apt-get update && apt-get dist-upgrade -y 11 | RUN apt-get install -y gdebi-core 12 | 13 | ENV COTURN_VER 4.4.5.3 14 | RUN cd /tmp/ && curl -sL http://turnserver.open-sys.org/downloads/v${COTURN_VER}/turnserver-${COTURN_VER}-debian-wheezy-ubuntu-mint-x86-64bits.tar.gz | tar -xzv 15 | 16 | RUN groupadd turnserver 17 | RUN useradd -g turnserver turnserver 18 | RUN gdebi -n /tmp/coturn*.deb 19 | 20 | RUN mkdir /etc/service/turnserver 21 | COPY turnserver.sh /etc/service/turnserver/run 22 | 23 | # Clean up APT when done. 24 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-turnserver 2 | ================= 3 | 4 | A Docker container with the Coturn STUN and TURN server (https://github.com/coturn/coturn) 5 | 6 | This is currently running v4.4.5.3. 7 | 8 | ``` 9 | docker run -d --name=turnserver --restart="on-failure:10" --net=host -p 3478:3478 -p 3478:3478/udp bprodoehl/turnserver 10 | ``` 11 | 12 | This will use icanhazip (http://major.io/icanhazip-com-faq/) to determine your container's public IP address. If you don't wish to use icanhazip, or you wish to use an external IP address that doesn't match what icanhazip would see, you can specify it in the environment: 13 | 14 | ``` 15 | docker run -d -e EXTERNAL_IP=1.2.3.4 --name=turnserver --restart="on-failure:10" --net=host -p 3478:3478 -p 3478:3478/udp bprodoehl/turnserver 16 | ``` 17 | 18 | Environment Parameters 19 | ----------------- 20 | * SKIP_AUTO_IP -- binds to any address, useful for IPv4 and IPv6 dual-stack when also running with --net=host 21 | * EXTERNAL_IP -- optional manually-specified external IP address 22 | * PORT -- listening port for STUN and TURN 23 | * LISTEN_ON_PUBLIC_IP -- bind to the external IP 24 | * USE_IPV4 -- forces IPv4 when determining the external IP 25 | -------------------------------------------------------------------------------- /turnserver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z $SKIP_AUTO_IP ] && [ -z $EXTERNAL_IP ] 4 | then 5 | if [ ! -z $USE_IPV4 ] 6 | then 7 | EXTERNAL_IP=`curl -4 icanhazip.com 2> /dev/null` 8 | else 9 | EXTERNAL_IP=`curl icanhazip.com 2> /dev/null` 10 | fi 11 | fi 12 | 13 | if [ -z $PORT ] 14 | then 15 | PORT=3478 16 | fi 17 | 18 | if [ ! -e /tmp/turnserver.configured ] 19 | then 20 | if [ -z $SKIP_AUTO_IP ] 21 | then 22 | echo external-ip=$EXTERNAL_IP > /etc/turnserver.conf 23 | fi 24 | echo listening-port=$PORT >> /etc/turnserver.conf 25 | 26 | if [ ! -z $LISTEN_ON_PUBLIC_IP ] 27 | then 28 | echo listening-ip=$EXTERNAL_IP >> /etc/turnserver.conf 29 | fi 30 | 31 | touch /tmp/turnserver.configured 32 | fi 33 | 34 | exec /usr/bin/turnserver --no-cli >>/var/log/turnserver.log 2>&1 35 | --------------------------------------------------------------------------------