Deploy OpenEMS Edge to Docker

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

Prerequisites:

  • A amd64 or arm64 device running Linux. You need the IP address and SSH access.

  • A working docker environment. To setup follow instruction from docs.docker.com.

1. Prepare system

1.1. Connect to the device

ssh admin@raspi5

1.2. Check docker installation

admin@raspi5:~$ 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-edge:
    image: openems/edge:latest
    container_name: openems_edge
    hostname: openems_edge
    restart: unless-stopped
    volumes:
      - openems-edge-conf:/var/opt/openems/config:rw
      - openems-edge-data:/var/opt/openems/data:rw
    ports:
      - 8080:8080 # Apache-Felix

volumes:
  openems-edge-conf:
  openems-edge-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@raspi5:~$ docker ps
CONTAINER ID  IMAGE                 COMMAND   CREATED               STATUS
0b2d32fe6203  openems/edge:latest   "/init"   About a minute ago    Up About a minute

or read its logs with:

docker logs openems_edge

3. OpenEMS Edge UI

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

services:
  openems-edge:
    image: openems/edge:latest
    container_name: openems_edge
    hostname: openems_edge
    restart: unless-stopped
    volumes:
      - openems-edge-conf:/var/opt/openems/config:rw
      - openems-edge-data:/var/opt/openems/data:rw
    ports:
      - 8080:8080 # Apache-Felix
      - 8085:8085 # UI-Websocket

  openems-ui:
    image: openems/ui-edge: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>:8085
    ports:
      - 80:80
      - 443:443

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

summary of the changes:

  1. Open a Port for UI Websocket (8085) on the openems-edge 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 Edge container. This URL is used by the UI to connect to the OpenEMS Edge 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-edge:latest  "/init"   About a minute ago    Up About a minute
0b2d32fe6203  openems/edge:latest     "/init"   About a minute ago    Up About a minute