Deploy OpenEMS Backend to Docker

This chapter explains how OpenEMS Backend can be deployed using our official Docker image.

1. Prepare system

1.1. Connect to the server

ssh admin@ubuntu

1.2. Check docker installation

admin@ubuntu:~$ docker --version
Docker version 27.3.1, build ce12230

if not already installed, follow Setup docker

1.3. Setup docker

To setup docker follow the instuctions from docs.docker.com.

2. Start Container

2.1. Create a Docker compose

Paste content into a docker-compose.yml

services:
  openems_backend:
    image: openems/backend:latest
    container_name: openems_backend
    hostname: openems_backend
    restart: unless-stopped
    volumes:
      - openems-backend-conf:/var/opt/openems/config:rw
      - openems-backend-data:/var/opt/openems/data:rw
    ports:
      - 8079:8079 # Apache-Felix
      - 8081:8081 # Edge-Websocket

volumes:
  openems-backend-conf:
  openems-backend-data:

2.2. Run compose file

To start the previously created docker-compose.yml run the command:

docker compose up -d

2.3. Check logs

To check if the container is up and running, check docker ps:

admin@ubuntu:~$ docker ps
CONTAINER ID  IMAGE                       COMMAND   CREATED               STATUS
15d5ba3c5f13  openems/backend:latest      "/init"   About a minute ago    Up About a minute

or read its logs with:

docker logs openems_backend

3. OpenEMS Backend UI

If you want to add the OpenEMS Backend UI to your setup, you can do so by adjusting your docker-compose.yml file to look like this:

services:
  openems_backend:
    image: openems/backend:latest
    container_name: openems_backend
    hostname: openems_backend
    restart: unless-stopped
    volumes:
      - openems-backend-conf:/var/opt/openems/config:rw
      - openems-backend-data:/var/opt/openems/data:rw
    ports:
      - 8079:8079 # Apache-Felix
      - 8081:8081 # Edge-Websocket
      - 8082:8082 # UI-Websocket

  openems-ui:
    image: openems/ui-backend:latest
    container_name: openems_ui
    hostname: openems_ui
    restart: unless-stopped
    volumes:
      - openems-ui-conf:/etc/nginx:rw
      - openems-ui-log:/var/log/nginx:rw
    environment:
      - UI_WEBSOCKET=ws://<hostname>:8082
    ports:
      - 80:80
      - 443:443

volumes:
  openems-backend-conf:
  openems-backend-data:
  openems-ui-conf:
  openems-ui-log:

summary of the changes:

  1. Open a Port for UI Websocket (8082) on the openems-backend service

  2. Added a new service openems-ui to the docker-compose file

  3. Added the volumes openems-ui-conf and openems-ui-log

The UI_WEBSOCKET environment variable must be set to the hostname of the OpenEMS Backend container. This URL is used by the UI to connect to the OpenEMS Backend Websocket. Make sure it is reachable from any device you want to use the UI on.

3.1. Update docker-compose

Update the compose running with: docker compose up -d

3.1.1. Check container status

admin@ubuntu:~$ docker ps
CONTAINER ID  IMAGE                       COMMAND   CREATED               STATUS
018187f444b1  openems/ui-backend:latest   "/init"   About a minute ago    Up About a minute
15d5ba3c5f13  openems/backend:latest      "/init"   About a minute ago    Up About a minute

4. Add InfluxDB Container

4.1. Update docker-compose

to add InfluxDB to your setup, you can do so by adjusting your docker-compose.yml, by adding the following lines:

  …
  openems_influxdb:
    image: influxdb:alpine
    container_name: openems_influxdb
    hostname: openems_influxdb
    restart: unless-stopped
    volumes:
      - openems-influxdb:/var/lib/influxdb2:rw
    ports:
      - 8086:8086

volumes:
  …
  openems-influxdb:

4.2. Setup InfluxDB

4.2.1. Setup InfluxDB

docker exec openems_influxdb influx setup \
  --username openems \
  --password WKeuIhl0deIJjrjoY62M \
  --org openems.io \
  --bucket openems \
  --force
docker exec openems_influxdb influx auth list
Note down Token

4.2.2. Open Backend Apache-Felix.

  1. Remove Timedata.Dummy

  2. Add Timedata.InfluxDB

Query Language

INFLUX_QL

URL

http://openems_influxdb:8086

Org

openems.io

ApiKey

InfluxDB-Token

Bucket

openems

Values not specified can be left at their default values Timedata.InfluxDB

for further information see OpenEMS docs