= Deploy OpenEMS Edge to Docker
:sectnums:
:sectnumlevels: 4
:toclevels: 4
:experimental:
:keywords: AsciiDoc
:source-highlighter: highlight.js
:icons: font
:imagesdir: ../../../assets/images


This chapter explains how OpenEMS can be deployed using our official https://hub.docker.com/r/openems/edge[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 https://docs.docker.com/engine/install/[docs.docker.com].

== Prepare system

=== Connect to the device

[source,bash]
----
ssh admin@raspi5
----

=== Check docker installation

[source,bash]
----
admin@raspi5:~$ docker --version
Docker version 27.3.1, build ce12230
----

__if not already installed, follow <<Setup docker>>__

=== Setup docker

To setup docker follow the instructions from https://docs.docker.com/engine/install/[docs.docker.com].

== Start Container 

=== Create a Docker compose

Paste content into a `docker-compose.yml` in a directory of your choice:

[source,yaml]
----
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:
----

=== Run compose file

To start the previously created `docker-compose.yml` `cd` into the directory of it and run the command:

[source,bash]
----
docker compose up -d
----

=== Check logs

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

[source,bash]
----
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:

[source,bash]
----
docker logs openems_edge
----

== 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:

[source,yaml]
----
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:
      - WEBSOCKET_HOST=openems_edge
      - WEBSOCKET_PORT=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`  

=== Update docker-compose

Update the compose running with: `docker compose up -d`

==== Check container status

[source,bash]
----
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
----

== InfluxDB

If you want to add the InfluxDB time series database to your setup, follow the https://openems.github.io/openems.io/openems/latest/backend/deploy/docker.html#_add_influxdb_container[OpenEMS Backend deploy instructions to setup InfluxDB].

== Changing the Language in the UI

To change the language in the OpenEMS UI:

1. Open the OpenEMS Edge UI in your browser.
2. Click the menu-icon in the top-left corner of the UI.
3. Click on the user to enter user settings.
4. Choose your preferred language from the "Sprache wählen"/"Select language" dropdown.
5. The UI will immediately switch to the selected language.

== Next Steps

After successful deployment:

1. Open your browser and go to `http://localhost` or the IP address of your device.
2. Log in using default credentials provided in the documentation.
3. Verify that your OpenEMS Edge instance is connected and running.
4. For additional configuration, see:
   * link:../controllers/[Edge Controllers Configuration]
   * link:../ui/[OpenEMS UI Usage Guide]
