Skip to content

The ResIOT team created a single, fully configurable image for ResIOT LoRaWAN Network Server & IoT Platform, the name is resiot/resiot:1000020

note 1: at each reboot the resiot/resiot:1000020 image proceeds with automatic updating to the latest version available
note 2: at the first start, wait a couple of minutes to allow time to perform all the necessary configurations

Here you can find 3 distinct examples:

1) Docker-Compose Basic Example with LoRaWAN Gateway connected via UDP

2) Docker Stack Multi Instance Basic Example with LoRaWAN Gateway connected via UDP

3) Docker Example

1) Docker-Compose Basic Example with LoRaWAN Gateway connected via UDP

In this example we have:

IP of the server to be reached from the outside and from the gateways: 155.156.157.158
Tcp port to access the platform via web: 58089
ResIOT Platform access address is: http://155.156.157.158:58089
Tcp port for Grpc protocol: 58096
Grpc host for gateway connection: 155.156.157.158:58096
Udp port for gateway connection: 57678
persistent volume folders to backup: ./resiotdata , ./rdbdata , ./dbdata
persistent volume for use by ResIOT for automatic updates and files that do not need to be backed up: ./resiotupdfld

remember to open the firewall ports:
58089 TCP
58096 TCP
57678 UDP

contents of docker-compose.yaml file:

version: "3.2"
services:
   dbresiot:
     image: postgres:12.5-alpine
     volumes:
       - ./dbdata:/var/lib/postgresql/data
     restart: always
     environment:
       POSTGRES_USER: resiotdb
       POSTGRES_PASSWORD: yourpasswordtest
       POSTGRES_DB: resiotcore
       PGDATA: /var/lib/postgresql/data/pgdata
   rdb:
     image: redis:5.0.10-alpine
     volumes:
       - ./rdbdata:/data
     restart: always
   mqtt:
     image: eclipse-mosquitto:1.6.12
     restart: always
   resiot:
     depends_on:
       - dbresiot
       - mqtt
       - rdb
     image: resiot/resiot:1000020
     ports:
       - "58089:8088"
       - "58096:8095"
       - "57678:7677/udp"
     volumes:
       - ./resiotupdfld:/run
       - ./resiotdata:/data
     restart: always
     environment:
       NO_LNS: n
       NO_PLA: n
       RESIOT_DB_TYPE: postgres
       RESIOT_DB_URL: postgres://resiotdb:yourpasswordtest@dbresiot:5432/resiotcore?sslmode=disable
       RESIOT_REDIS_URL: redis://rdb:6379
       RESIOT_MQTT_URL: tcp://mqtt:1883
       RESIOT_LORA_BAND: EU_863_870
       RESIOT_LORA_NETID: A0B1B2
       RESIOT_EXTERNAL_ACCESS_UDP_HOST: 155.156.157.158
       RESIOT_EXTERNAL_ACCESS_UDP_PORT: 57678
       RESIOT_EXTERNAL_ACCESS_GRPC_HOST: 155.156.157.158:58096

2) Docker Stack Multi Instance Basic Example with LoRaWAN Gateway connected via UDP

This example allows you to create an example deployment with 3 ResIOT instances in HA with Docker stack
In this example we have:
IP of the server to be reached from the outside and from the gateways: 155.156.157.158
Tcp port to access the platform via web: 58089
ResIOT Platform access address is: http://155.156.157.158:58089
Tcp port for Grpc protocol: 58096
Grpc host for gateway connection: 155.156.157.158:58096
Udp port for gateway connection: 57678
persistent volume folders to backup: ./resiotdata , ./rdbdata , ./dbdata
persistent volume for use by ResIOT for automatic updates and files that do not need to be backed up: ./resiotupdfld

remember to open the firewall ports:
58089 TCP
58096 TCP
57678 UDP

this example includes two files docker-compose-stack.yaml and nginx.conf to be created in the same folder
follow the next three step

Step 1 - contents of docker-compose-stack.yaml file:

version: "3.2"
services:
   dbresiot:
     image: postgres:12.5-alpine
     volumes:
       - ./dbdata:/var/lib/postgresql/data
     restart: always
     environment:
       POSTGRES_USER: resiotdb
       POSTGRES_PASSWORD: yourpasswordtest
       POSTGRES_DB: resiotcore
       PGDATA: /var/lib/postgresql/data/pgdata
   rdb:
     image: redis:5.0.10-alpine
     volumes:
       - ./rdbdata:/data
     restart: always
   mqtt:
     image: eclipse-mosquitto:1.6.12
     restart: always
   resiot:
     depends_on:
       - dbresiot
       - mqtt
       - rdb
     image: resiot/resiot:1000020
     deploy:
       replicas: 3
     expose:
       - "8088"
       - "8095"
       - "7677/udp"
     volumes:
       - ./resiotupdfld:/run
       - ./resiotdata:/data
     restart: always
     environment:
       NO_LNS: "n"
       NO_PLA: "n"
       RESIOT_DB_TYPE: postgres
       RESIOT_DB_URL: postgres://resiotdb:yourpasswordtest@dbresiot:5432/resiotcore?sslmode=disable
       RESIOT_REDIS_URL: redis://rdb:6379
       RESIOT_MQTT_URL: tcp://mqtt:1883
       RESIOT_LORA_BAND: EU_863_870
       RESIOT_LORA_NETID: A0A1A2
       RESIOT_EXTERNAL_ACCESS_UDP_HOST: 155.156.157.158
       RESIOT_EXTERNAL_ACCESS_UDP_PORT: 57678
       RESIOT_EXTERNAL_ACCESS_GRPC_HOST: 155.156.157.158:58096
   nginx:
     image: nginx:latest
     volumes:
       - ./nginx.conf:/etc/nginx/nginx.conf:ro
     depends_on:
       - resiot
     ports:
       - "58089:58089"
       - "58096:58096"
       - "57678:57678/udp"

Step 2 - contents of nginx.conf file:

user  nginx;
events {
    worker_connections   1000;
}
http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }
    upstream resiottcp_8088_backend {
        server resiot:8088;
    }
    server {
        listen 58089;
        location / {
                        proxy_pass http://resiottcp_8088_backend;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection $connection_upgrade;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header X-Forwarded-Proto http;
                        proxy_read_timeout 36000s;
                        proxy_redirect off;
        }
    }
    server {
        listen 58096 http2;
        location / {
                        grpc_pass grpc://resiot:8095;
        }
    }
}
stream {
    upstream resiotudp_7677_backend {
        server resiot:7677;
    }
    server {
        listen 57678 udp;
        proxy_pass resiotudp_7677_backend;
    }
}

Step 3 - Docker stack deployment

# in the folder where the docker-compose-stack.yaml and nginx.conf files are present i create the folders dbdata,rdbdata,resiotdata and resiotupdfld
# example for linux:
sudo mkdir dbdata ; sudo mkdir rdbdata ; sudo mkdir resiotdata ; sudo mkdir resiotupdfld

# docker stack deploy with name stack0001
sudo docker stack deploy --compose-file docker-compose-stack.yaml stack0001

(you can also use docker-compose with sudo docker-compose --compatibility up
for testing but without replication because on a machine it is not managed correctly as in particular configurations all the instances restart simultaneously losing the condition of ha)

# now visit http://155.156.157.158:58089 after two/three minutes

# Other commands:
# see active services
sudo docker stack services stack0001

# to see the logs
sudo docker service logs stack0001_resiot
sudo docker service logs stack0001_nginx
sudo docker service logs stack0001_dbresiot
sudo docker service logs stack0001_mqtt
sudo docker service logs stack0001_rdb

# to delete
sudo docker stack rm stack0001
sudo rm -rf dbdata ; sudo rm -rf rdbdata ; sudo rm -rf resiotdata ; sudo rm -rf resiotupdfld

3) Docker Example

for this example it is assumed that we have a postgres database installed, redis and mosquitto mqtt at 172.17.0.1 ip address

sudo mkdir -p /opt/resiot00001

sudo nano /opt/resiot00001/config.json
Contents of file config.json:
{
        "RESIOT_DB_TYPE": "postgres",
        "RESIOT_DB_URL": "postgres://resiotdb:[yourpwd]@172.17.0.1:5432/resiotcore?sslmode=disable",
        "RESIOT_REDIS_URL": "redis://172.17.0.1:6379",
        "RESIOT_MQTT_URL": "tcp://172.17.0.1:1883",
        "RESIOT_MQTT_USER": "",
        "RESIOT_MQTT_PWD": "",
        "RESIOT_MQTT_CACERT": "",
        "RESIOT_LORA_BAND": "EU_863_870",
        "RESIOT_LORA_NETID": "A0A1A2"
}

sudo docker pull resiot/resiot:1000020

sudo docker run -d --name resiot00001 -v /opt/resiot00001/updfld00001:/run -v /opt/resiot00001/data00001:/data -v /opt/resiot00001/config.json:/cfg/config.json -p 58088:8088 -p 58095:8095 -p 57677:7677/udp  resiot/resiot:1000020

Web browser to: http://localhost:58088 for viewing ResIOT

Other commands

to set always restart even on reboot system
sudo docker update --restart always resiot00001

to kill container: 
sudo docker kill resiot00001

to remove container:
sudo docker container rm resiot00001

to kill and remove container: 
sudo docker kill resiot00001 ; sudo docker container rm resiot00001

to exec a command inside container (ex: ps aux):
sudo docker exec -it resiot00001 ps aux

to view container logs:
sudo docker logs -f resiot00001
sudo docker logs -f --until=2s resiot00001