In order to make some tests, I run multiple docker instances in the same machine. I use OPENHAB_HTTP_PORT (and S) to change access ports; but SSH and LSP are missing. Could some more environment variables be added to change them?
OPENHAB_SSH_PORT and OPENHAB_LSP_PORT are supported too, afaik.
See below
The only reference to this I could found is in Contributing | OpenHAB JRuby Script Library
I checked adding them to my docker-compose.yml:
services:
openhab:
image: "openhab/openhab:latest-debian"
container_name: openhab-latest
restart: no
network_mode: host
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
- "/run/mysqld:/run/mysqld"
- "./addons:/openhab/addons"
- "./conf:/openhab/conf"
- "./userdata:/openhab/userdata"
- "./backups:/openhab/backups"
cap_add:
- NET_ADMIN
- NET_RAW
environment:
CRYPTO_POLICY: "unlimited"
EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Madrid"
OPENHAB_HTTP_PORT: "8086"
OPENHAB_HTTPS_PORT: "8446"
OPENHAB_SSH_PORT: "9922"
OPENHAB_LSP_PORT: "9923"
USER_ID: 136
GROUP_ID: 147
But ports aren’t changed:
2024-09-03 13:52:44.896 [ERROR] [che.sshd.common.io.nio2.Nio2Acceptor] - bind(/127.0.0.1:8101) - failed (BindException│root@servidor7:~# cd /mnt/md0/docker/openhab-latest/
) to bind: Address already in use │root@servidor7:/mnt/md0/docker/openhab-latest# tail -f userdata/logs/
2024-09-03 13:52:44.917 [WARN ] [org.apache.karaf.shell.ssh.Activator] - Exception caught while starting SSH server │events.log openhab.log
java.net.BindException: Address already in use
....
2024-09-03 13:52:56.240 [ERROR] [.core.model.lsp.internal.ModelServer] - Error starting the Language Server │^C
java.net.BindException: Address already in use
Ahh indeed! (I was the one adding those to jruby ci)
Sorry, forget the environment variables. You need to write into conf/services/runtime.cfg
org.apache.karaf.shell:sshPort = 9922
org.openhab.lsp:port = 9923
Before using docker I used to edit config files; but as I keep deleting all config files to make clean install/configure, I was asking if this could be done/added.
Thanks.
not a bad idea
I’m confused here. Why can’t you use port mapping in this case? Are you trying to run multiple instances of OH and have them all use host networking? Do you need network discovery or something like that which requires host networking? Maybe this is an XY Problem.
Note I’m not arguing that these ports shouldn’t be controllable through environment variables.
You are right (as usual). Some times I should step back and look again at the problems from start.
I have taken my working docker-compose.yml; and started a new instance to check if I better upgrade, rebuild everything, check what have changed, …
That’s why I am using network_mode:host
.