Deploy OpenEMS Backend to Docker
This chapter explains how OpenEMS Backend can be deployed using our official Docker image.
The involved components (Edge.Manager, Backend.Edge.App) and the available deployment options are described in Backend Architecture. The Docker images follow this architecture: the openems/backend image contains the central Backend with the Edge Manager, while the separate openems/backend-edge image runs the Backend Edge Application that the OpenEMS Edge devices connect to.
1. Prepare system
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 instructions from docs.docker.com.
2. Start Container
2.1. Create a Docker compose
Paste content into a docker-compose.yml in a directory of your choice:
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
openems_backend_edge:
image: openems/backend-edge:latest
container_name: openems_backend_edge
hostname: openems-backend-edge
restart: unless-stopped
volumes:
- openems-backend-edge-conf:/var/opt/openems/config:rw
- openems-backend-edge-data:/var/opt/openems/data:rw
ports:
- 8078:8078 # Apache-Felix
- 8081:8081 # Edge-Websocket
volumes:
openems-backend-conf:
openems-backend-data:
openems-backend-edge-conf:
openems-backend-edge-data:
2.2. Run compose file
To start the previously created docker-compose.yml cd into the directory of it and 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
018187f444b1 openems/backend-edge:latest "/init" About a minute ago Up About a minute
or read its logs with:
docker logs openems_backend
2.4. Connect the Backend Edge Application
The Backend Edge Application in the openems/backend-edge container needs to connect to the Edge Manager in the openems/backend container.
-
Open the Apache Felix Web Console Configuration of the openems/backend-edge container.
Login with username admin and password admin.
-
Configure the Backend Edge Application service: set Uri to the address of the openems/backend container, e.g.
ws://openems_backend:8083.The port must match the Port of the Edge Manager service in the openems/backend container (default
8083). Click Save.
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
- 8082:8082 # UI-Websocket
openems_backend_edge:
image: openems/backend-edge:latest
container_name: openems_backend_edge
hostname: openems-backend-edge
restart: unless-stopped
volumes:
- openems-backend-edge-conf:/var/opt/openems/config:rw
- openems-backend-edge-data:/var/opt/openems/data:rw
ports:
- 8078:8078 # Apache-Felix
- 8081:8081 # Edge-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:
- WEBSOCKET_HOST=openems_backend
- WEBSOCKET_PORT=8082
ports:
- 80:80
- 443:443
volumes:
openems-backend-conf:
openems-backend-data:
openems-backend-edge-conf:
openems-backend-edge-data:
openems-ui-conf:
openems-ui-log:
summary of the changes:
-
Open a Port for UI Websocket (8082) on the
openems-backendservice -
Added a new service
openems-uito the docker-compose file -
Added the volumes
openems-ui-confandopenems-ui-log
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
2a6c8d9f0b53 openems/backend-edge: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:2.9-alpine
container_name: openems-influxdb
hostname: openems-influxdb
restart: unless-stopped
volumes:
- openems-influxdb2-data:/var/lib/influxdb2:rw
ports:
- 8086:8086
volumes:
…
openems-influxdb2-data:
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.
Open the Apache Felix Web Console Configuration of the openems/backend container and login with username admin and password admin.
-
Remove Timedata.Dummy
-
Add Timedata.InfluxDB
Query Language |
INFLUX_QL |
URL |
|
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