For all you docker experts
How do I stop openhab within the running container?
I don’t want to stop the container
if I get to the command line of the running container using
docker exec -it openhab /bin/bash
and I try
systemctl stop openhab
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
here is my docker command if it matters
docker run \
--name openhab \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/timezone:/etc/timezone:ro \
-v openhab_addons:/openhab/addons \
-v openhab_conf:/openhab/conf \
-v openhab_userdata:/openhab/userdata \
-e "EXTRA_JAVA_OPTS=-Duser.timezone=America/New_York" \
-e OPENHAB_HTTP_PORT=8181 \
-e OPENHAB_HTTPS_PORT=8544 \
why would you like to do that ?
As far as I understand there is only one process ( java ) running in that container and in case you would kill that process it would be restarted because of restart=always.
You don’t. Once the openHAB process ends the container ends too. In general containers are not really set up to support running multiple processes at the same time. There’s no init daemon nor any systemd daemon controlling startup and shutdown of services. And once the one process that is running in the container, the container itself exists.
You can run more than one service at a time in a container but that’s some what of an anti-pattern, though sometimes unavoidable. But to do that you have to set it up to support that yourself by running one or more of the processes in the background. But still the container will exit when the primary process exits so when you kill openHAB the container will exit too, taking all the other processes running in the background down with it.
A container is not a virtual machine. It is not a full OS with multitasking and all the services necessary to run a modern machine. When a Docker image is well designed, it contains just enough to run the one service and nothing more.
Thank you for the help guys!
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.