Build WebRTC Janus with Docker container

Introduction

This is a record of the procedure for building a Docker container image of Janus of WebRTC. The constructed Docker container image will be published on Docker Hub. If you want to try the Docker container image created in this procedure immediately, follow the procedure of Launch Janus service from public image of Docker Hub.

Prerequisites

Implementation environment

MacBook Air (M1, 2020) Mac OS Big Sur 11.0.1 PREVIEW version for Docker Desktop Silicon MAC Container base image: Debian

Container initial settings

#Get container image
$docker pull debian

#Container startup
$docker run -itd debian /bin/sh

#Confirm container ID
$docker ps -a

#Shell into the container
$docker exec -it container ID bash

#update
$apt-get update

#Required library installation
$apt install libmicrohttpd-dev libjansson-dev libssl-dev \
 libsofia-sip-ua-dev libglib2.0-dev libopus-dev libogg-dev \
 libcurl4-openssl-dev liblua5.3-dev libconfig-dev \
 pkg-config gengetopt libtool automake gtk-doc-tools doxygen \
 graphviz libnanomsg-dev cmake -y --fix-missing
#Install the command used for installation
$apt-get install -y wget && \
 apt-get install vim -y && \
 apt-get install git -y && \
 apt-get install -y curl

Required library installation

#libnice
$PATH="/usr/local/bin:$PATH"
$apt install python3-pip
$pip3 install meson
$pip3 install ninja
$cd ~
$git clone https://gitlab.freedesktop.org/libnice/libnice
$cd libnice
$meson --prefix=/usr build && ninja -C build && ninja -C build install

#libsrtp
$cd ~
$wget https://github.com/cisco/libsrtp/archive/v2.2.0.tar.gz
$tar xfv v2.2.0.tar.gz
$cd libsrtp-2.2.0
$./configure --prefix=/usr --enable-openssl
$make shared_library && make install

#usrsctp
$cd ~
$git clone https://github.com/sctplab/usrsctp
$cd usrsctp
$./bootstrap
$./configure --prefix=/usr --disable-programs --disable-inet --disable-inet6
$make && make install

#libwebsockets
$cd ~
$git clone https://libwebsockets.org/repo/libwebsockets
$cd libwebsockets
$mkdir build
$cd build
$cmake -DLWS_MAX_SMP=1 -DLWS_WITHOUT_EXTENSIONS=0 \
  -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_C_FLAGS="-fpic" ..
$make && make install

Install the Janus server itself

$cd ~
$git clone https://github.com/meetecho/janus-gateway.git
$cd janus-gateway
$sh autogen.sh
$./configure --prefix=/opt/janus
$make
$make install
$make configs

Operation check of Janus server

#Service start
$/opt/janus/bin/janus&

#Confirm that there is a Json response of the Janus server with the curl command
$curl http://localhost:8088/janus/info

#end janus process
$ps aux | grep janus | grep -v grep | awk '{ print "kill -9", $2 }' | sh

Set up Janus demo client

#node,npm install
$apt-get install nodejs npm

#Since the version of npm is old, install the latest version with version control
$npm install n -g
$n stable

#Remove old nodejs npm version
$apt purge -y nodejs npm

#Reboot the shell
$exec $SHELL -l

#Check version
$node -v

#Simple web server (local-web-server) installation
$npm install -g local-web-server

Set Janus launch shell

$cd ~/janus-gateway
$touch run_janus.sh
$echo "/opt/janus/bin/janus &" >>run_janus.sh
$echo "cd /root/janus-gateway/html" >>run_janus.sh
$echo "ws&" >>run_janus.sh
$chmod 755 run_janus.sh

Execute Janus startup shell and check the operation

#Janus server starts demo
$~/janus-gateway/run_janus.sh

#Janus server, demo operation check
$curl http://localhost:8000
$curl http://localhost:8088/janus/info

#Exit the container and return to the console on the host side
$exit

Container image creation

Create a container image on the host side.

#Confirmation of the container ID you were working on
$docker ps -a

#Stop container to create image
$docker stop container ID

#Container image creation
$docker commit container ID janus

#Delete the container you were working on
$docker rm container ID

Create a container from the created container image

$docker run -itd -p 8088:8088 -p 8000:8000 --name janus janus \
  /bin/bash -c "/root/janus-gateway/run_janus.sh;/bin/sh"

Port forward with "-p 8088: 8088 -p 8000: 8000" so that the Janus server and client services can be accessed from the browser in the local environment. Execute the startup shell with "/ bin/bash -c" so that the Janus server and client are started when the container is started.

Check the operation of Janus demo from the browser

Access the demo page (http://127.0.0.1:8000/videoroomtest.html) from your browser and check that Janus's video room etc. can be used. Click the START button on the upper right and enter the room name, and the camera image of your computer will be displayed on the browser. 01.jpg 02.jpg 03.jpg

Publish the created Docker image to Docker HUB

#Confirmation of the container ID you were working on
$docker ps -a

#Stop container to create image
$docker stop container ID

#Log in to Docker Hub (enter user and password)
$docker login

#Docker image creation
$docker commit container ID pyuta/janus-local-run:latest

#Check the image ID of the Docker image
$docker images

#Push to Docker Hub
$docker push pyuta/janus-local-run:latest

Container launch of Janus service from public image of Docker HUB

$docker run -itd -p 8088:8088 -p 8000:8000 --name janus \
  pyuta/janus-local-run:latest \
  /bin/bash -c "/root/janus-gateway/run_janus.sh;/bin/sh"

Access the demo page (http://127.0.0.1:8000/videoroomtest.html) from your browser and check that Janus's video room etc. can be used. Click the START button on the upper right and enter the room name, and the camera image of your computer will be displayed on the browser. 01.jpg

Future response

Now that we have containerized the Janus service in our local Docker environment, our next goal is to create a container image that can be used directly and externally.

** Addendum ** I made the described procedure into a Dockerfile. Publish with Create Web RTC Janus container with Dockerfile -Qiita.

Recommended Posts

Build WebRTC Janus with Docker container
Build DynamoDB local with Docker
Build Couchbase local environment with Docker
Build a Node.js environment with Docker
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
[Linux] Start Apache container with Docker
Build docker + laravel environment with laradock
Spring Boot gradle build with Docker
Build a PureScript development environment with Docker
Quick build maven project using maven docker container
Build a Wordpress development environment with Docker
[Docker] Build Jupyter Lab execution environment with Docker
Build an environment with Docker on AWS
Build TensorFlow operation check environment with Docker
How to build Rails 6 environment with Docker
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Small Docker container
Template: Build a Ruby / Rails development environment with a Docker container (Ubuntu version)
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Build a Laravel / Docker environment with VSCode devcontainer
Keep docker container running with no resident process running
Build a Kotlin app using OpenJDK's Docker container
Setting to exit from Docker container with VScode
Build a container for Docker x Laravel phpMyAdmin
Update container image with KUSANAGI Runs on Docker
Docker Container Operations with Docker-Client API for Java
Build mecab (NEologd dictionary) environment with Docker (ubuntu)
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
Build Elastic Stack with Docker and analyze IIS logs
Build a docker container for a python simple web server
How to build docker environment with Gradle for intelliJ
Build an environment of Ruby2.7.x + Rails6.0.x + MySQL8.0.x with Docker
Launch MariaDB with Docker
Access and debug Circle CI Docker container with ssh
Run Pico with docker
Build Doma1 with Ant
Easily build a Vue.js environment with Docker + Vue CLI
Explode Docker with WSL2
Use Puphpeteer with Docker
[Note] Build a Python3 environment with Docker in EC2
Operate Emby with Docker
Try WildFly with Docker
[Note] I suddenly can't build with Docker for windows.
Use ngrok with Docker
Run Payara with Docker
Build Growai with Centos7
(For myself) Build gitlab with ubuntu18.04 + docker for home (Note)
[Docker] Connection with MySQL
Build Java development environment with WSL2 Docker VS Code
[Docker] Build an Apache container on EC2 using dockerfile
Php settings with Docker
Getting Started with Docker
Build Rails (API) x MySQL x Nuxt.js environment with Docker
Docker container usage scene
Disposable PHP with Docker
Build bazel with alpine
Install Composer with Docker
Proceed with Rust official documentation on Docker container (1. Getting started)
Wait for the container service to start with docker healthcheck