openhab / openhab-docker

Repository for building Docker containers for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
209 stars 128 forks source link

Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ || exit 1 #408

Closed Ashcora closed 1 year ago

Ashcora commented 1 year ago

Portainer Event Log is showing frequent and repeated entries

2022-10-19 16:23:00 | container | Exec instance exited 2022-10-19 16:23:00 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:23:00 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:18:00 | container | Exec instance exited 2022-10-19 16:17:59 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:17:59 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:12:59 | container | Exec instance exited 2022-10-19 16:12:59 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:12:59 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:07:59 | container | Exec instance exited 2022-10-19 16:07:59 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:07:59 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:02:59 | container | Exec instance exited 2022-10-19 16:02:59 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 16:02:59 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 15:57:59 | container | Exec instance exited 2022-10-19 15:57:59 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-19 15:57:59 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1

Summary

Log files within Portainer show events with regard to OPENHAB_HTTP_PORT

Expected Behavior

No error events are shown in the event log.

Current Behavior

container | Exec instance exited container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ || exit 1 container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ || exit 1

Possible Solution

Adapt configuration and/or start command to fix these entries.

Steps to Reproduce

docker run \ --name openhab \ --net=host \ -v /etc/localtime:/etc/localtime:ro \ -v /etc/timezone:/etc/timezone:ro \ -v /opt/openhab/conf:/openhab/conf \ -v /opt/openhab/userdata:/openhab/userdata \ -v /opt/openhab/addons:/openhab/addons\ -d \ -e OPENHAB_HTTP_PORT=8081 \ -e OPENHAB_HTTPS_PORT=8444 \ -e USER_ID=$USER_ID \ -e GROUP_ID=$GROUP_ID \ --restart=always \ openhab/openhab:latest

Context

These entries are spamming the event log

Your Environment

Raspberry Pi 4 Model B Rev 1.5 Docker version 20.10.5+dfsg1, build 55c4c88

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"

Image

openhab/openhab:latest Debian GNU/Linux 11 (bullseye)

Docker Host

pi@raspberrypi4:~ $ docker info Client: Context: default Debug Mode: false Plugins: compose: Docker Compose (Docker Inc., v2.12.0)

Server: Containers: 4 Running: 3 Paused: 0 Stopped: 1 Images: 4 Server Version: 20.10.5+dfsg1 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 1.4.13~ds1-1~deb11u2 runc version: 1.0.0~rc93+ds1-5+deb11u2 init version: Security Options: seccomp Profile: default cgroupns Kernel Version: 5.15.65-v8+ Operating System: Debian GNU/Linux 11 (bullseye) OSType: linux Architecture: aarch64 CPUs: 4 Total Memory: 7.629GiB Name: raspberrypi4 ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false

Configuration

Start via Docker run command

wborn commented 1 year ago

It works fine for me if I change the HTTP port. Maybe the Docker container logging or openHAB logging helps explaining why the container exits?

Ashcora commented 1 year ago

@wborn : Thank you for your suggestion. I tried to run the OpenHab Container with changing the HTTP port from 8081 to 8084. For me it does not work. The event log directly triggers the message again.

2022-10-29 12:43:53 | container | Exec instance exited -- | -- | -- 2022-10-29 12:43:53 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-29 12:43:53 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-29 12:38:53 | container | Container openhab executed health status: healthy 2022-10-29 12:38:52 | container | Exec instance exited 2022-10-29 12:38:52 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-29 12:38:52 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-29 12:33:52 | container | Container openhab started

In the OpenHab log nothing is listed at all :(

/etc/ssl/certs/adoptium/cacerts successfully populated.
+ capsh --print
+ grep -E Current:.+,cap_net_admin,cap_net_raw,.+
+ rm -f /openhab/runtime/instances/instance.properties
+ rm -f /openhab/userdata/tmp/instances/instance.properties
+ NEW_USER_ID=9001
+ NEW_GROUP_ID=9001
+ echo 'Starting with openhab user id: 9001 and group id: 9001'
Starting with openhab user id: 9001 and group id: 9001
+ id -u openhab
++ getent group 9001
+ '[' -z '' ']'
+ echo 'Create group openhab with id 9001'
Create group openhab with id 9001
+ groupadd -g 9001 openhab
+ echo 'Create user openhab with id 9001'
Create user openhab with id 9001
+ adduser -u 9001 --disabled-password --gecos '' --home /openhab --gid 9001 openhab
Warning: The home dir /openhab you specified already exists.
Adding user `openhab' ...
Adding new user `openhab' (9001) with group `openhab' ...
adduser: Warning: The home directory `/openhab' does not belong to the user you are currently creating.
The home directory `/openhab' already exists.  Not copying from `/etc/skel'.
+ groupadd -g 14 uucp2
+ groupadd -g 16 dialout2
+ groupadd -g 18 dialout3
+ groupadd -g 32 uucp3
+ groupadd -g 997 gpio
+ adduser openhab dialout
Adding user `openhab' to group `dialout' ...
Adding user openhab to group dialout
Done.
+ adduser openhab uucp
Adding user `openhab' to group `uucp' ...
Adding user openhab to group uucp
Done.
+ adduser openhab uucp2
Adding user `openhab' to group `uucp2' ...
Adding user openhab to group uucp2
Done.
+ adduser openhab dialout2
Adding user `openhab' to group `dialout2' ...
Adding user openhab to group dialout2
Done.
+ adduser openhab dialout3
Adding user `openhab' to group `dialout3' ...
Adding user openhab to group dialout3
Done.
+ adduser openhab uucp3
Adding user `openhab' to group `uucp3' ...
Adding user openhab to group uucp3
Done.
+ adduser openhab gpio
Adding user `openhab' to group `gpio' ...
Adding user openhab to group gpio
Done.
+ initialize_volume /openhab/conf /openhab/dist/conf
+ volume=/openhab/conf
+ source=/openhab/dist/conf
++ ls -A /openhab/conf
+ '[' -z 'automation
html
icons
items
misc
persistence
rules
scripts
services
sitemaps
sounds
things
transform' ']'
+ initialize_volume /openhab/userdata /openhab/dist/userdata
+ volume=/openhab/userdata
+ source=/openhab/dist/userdata
++ ls -A /openhab/userdata
+ '[' -z 'cache
config
etc
jsondb
kar
logs
marketplace
persistence
secrets
tmp' ']'
++ cmp /openhab/userdata/etc/version.properties /openhab/dist/userdata/etc/version.properties
+ '[' '!' -z ']'
+ chown -R openhab:openhab /openhab
+ sync
+ '[' -d /etc/cont-init.d ']'
+ sync
+ '[' false == false ']'
++ IFS=' '
++ echo gosu openhab tini -s ./start.sh
+ '[' 'gosu openhab tini -s ./start.sh' == 'gosu openhab tini -s ./start.sh' ']'
+ command=($@ server)
+ exec gosu openhab tini -s ./start.sh server
Launching the openHAB runtime...
wborn commented 1 year ago

It seems to start but if it fails it will log the reason to userdata/logs/openhab.log. Can you attach that file?

Ashcora commented 1 year ago

So I killed the container again, deleted the log files and created the container again.

2022-10-30 00:23:33 | container | Container openhab executed health status: healthy -- | -- | -- 2022-10-30 00:23:33 | container | Exec instance exited 2022-10-30 00:23:33 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-10-30 00:23:33 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1

but having a look into the log file, it has no entry at 00:23:33, see log attached openhab.log

wborn commented 1 year ago

There's no error in the log file. Perhaps there is a hs_err_pid .log file in the userdata/ dir? Such files contain details of JVM crashes.

Ashcora commented 1 year ago

@wborn : Unfortunately, no such log file exists. See the output of "find /opt/openhab/ -type f -name '.log' -printf '%f\t%p\n' | sort -k1 | cut -d$'\t' -f2" below:

/opt/openhab/userdata/logs/audit.log /opt/openhab/userdata/logs/events.log.1.gz /opt/openhab/userdata/logs/events.log.2.gz /opt/openhab/userdata/logs/events.log.3.gz /opt/openhab/userdata/logs/events.log.4.gz /opt/openhab/userdata/logs/events.log.5.gz /opt/openhab/userdata/logs/events.log.6.gz /opt/openhab/userdata/logs/events.log.7.gz /opt/openhab/userdata/logs/events.log /opt/openhab/userdata/etc/java.util.logging.properties /opt/openhab/userdata/logs/openhab.log.1.gz /opt/openhab/userdata/logs/openhab.log.2.gz /opt/openhab/userdata/logs/openhab.log.3.gz /opt/openhab/userdata/logs/openhab.log.4.gz /opt/openhab/userdata/logs/openhab.log.5.gz /opt/openhab/userdata/logs/openhab.log.6.gz /opt/openhab/userdata/logs/openhab.log.7.gz /opt/openhab/userdata/logs/openhab.log /opt/openhab/userdata/etc/org.apache.karaf.log.cfg /opt/openhab/userdata/etc/org.ops4j.pax.logging.cfg /opt/openhab/userdata/etc/org.apache.karaf.log.cfg /opt/openhab/userdata/etc/java.util.logging.properties

wborn commented 1 year ago

Seems like there is not enough info then to further help troubleshooting this issue. Perhaps the issue is due to some kind of specific network or docker configuration that you use on that host.

wborn commented 1 year ago

Maybe there is someone in the Community who also ran into this issue. :slightly_smiling_face:

Try creating a topic for it here: https://community.openhab.org/tags/c/setup-configuration-and-use/docker

Ashcora commented 1 year ago

Even with a new container and an "empty" (non-modified) configuration I see the entries in the events of Portainer.

2022-11-05 11:53:52 | container | Container openhab executed health status: healthy -- | -- | -- 2022-11-05 11:53:52 | container | Exec instance exited 2022-11-05 11:53:51 | container | Exec instance started: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1 2022-11-05 11:53:51 | container | Exec instance created: /bin/sh -c curl -f http://localhost:${OPENHAB_HTTP_PORT}/ \|\| exit 1

I might ask the community for help. Thanks for the hint.

Ashcora commented 1 year ago

Using the following command, the issue is not coming up: --no-healthcheck