Trying to run open in Podman with no succes

  • Platform information:
    • Hardware: hp tower 800 g1 i7
    • OS: RHEL 9
    • Java Runtime Environment: OpenJDK 17
    • openHAB version: 3.3.3
  • Issue of the topic: i can not make open run on podman. I triede many option.
    I am a beginner and i made home assistant run easy but openhab doesnt work.
    It keeps restarting.

I just want a simple podman run code to get openhab running and figure out someday later how other stuff with podman works.

This is my code in podman but keeps at saying lauching openhab. With different command lines.

Home assistant required this code and podman works

run -d --name homeassistant --cap-add=CAP_NET_RAW,CAP_NET_BIND_SERVICE --restart=unless-stopped -p 8123:8123 -v /etc/localtime:/etc/localtime:ro -v ~/hass/config:/config:Z -v ~/hass/media:/media:Z --pull=always homeassistant/home-assistant:stable

But for openhab i cant get it to run maybe some one did.

podman run -d --name openhab --cap-add=CAP_NET_RAW,CAP_NET_BIND_nSERVICE --restart=unless-stopped -p 8050:8050 -v /etc/localtime:/etc/localtime:ro -v ~/opt/openhab/openhab_addons:/openhab/addons -v ~/opt/openhab/openhab_conf:/openhab/conf -v ~/opt/openhab/openhab_userdata:/openhab/userdata --pull=always openhab/openhab:3.3.0

  • Please post configurations (if applicable):
    • Items configuration related to the issue
    • Sitemap configuration related to the issue
    • Rules code related to the issue
    • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

You have to sort that part out, or you may be wasting your time on the rest.

Hi

This works for me (note that I am using SELinux, hence the :Z things) with a host user openhab with uid and gid set to 9001:9001:

/usr/bin/podman run --name=openhab --net=host   -v /etc/localtime:/etc/localtime:ro   -v /etc/timezone:/etc/timezone:ro   -v /opt/openhab/conf:/openhab/conf:Z   -v /opt/openhab/userdata:/openhab/userdata:Z   -v /opt/openhab/addons:/openhab/addons:Z   -v /opt/openhab/.java:/openhab/.java:Z   --env CRYPTO_POLICY=unlimited   -e USER_ID=9001 -e GROUP_ID=9001 -d docker.io/openhab/openhab:3.3.0-alpine

Don’t you get any error?

Hi,
in docker log, the last line also for me is

openhab_1_abc1cdae37c5 | Launching the openHAB runtime...

and it works perfectly well (openhab:3.3.0, but with docker not podman)

so probably it is actually running? If you just can’t open the web page, this might be due to port which is 8080 as default as far as I understand, not 8050.

Hi there this is whats included in rhel 9
OpenJDK 17 Java Runtime Environment and the OpenJDK 17 Java Software Development Kit

No experience where this would be useful?
Because openhab is written in java?

Yes. And openHAB 3 only supports Java 11.

Since you run openhab in a container with (correct) java the host systems java is not relevant.

Try running your command without -d option and see what is getting printed to the console. IE remove -d from

podman run -d 


1 Like

Can someone guide me a little bit?

-v

writing to the folders?

:Z
Why do i need to put :Z on the end of the directory

After this the permission to write went away
–privileged

Why is it used and why would it be useful?
-d

What does detach mean and why would jou want it? Detach didnt show log but after running podman run openhab container log it show permission denied. Why?
–net=host --network=host

Does not give any port to my container. Dont understand why.
–cap-add=CAP_NET_RAW,CAP_NET_BIND_nSERVICE –

I cant make up this command that i copy and paste from the home assistant command

restart=unless-stopped
That what it did with last code when it didn’t get further then starting the container. It kept restarting.

Some command line use --init
Not sure why but i do see it sometimes.

-p 8050:8050
This is just some port I thought was handy because some application requires 8080 port.

So I thought changing the port it schould not be to busy. Or to have control over the ports.

I that correct or does the openhab image just only work with 8080 port? Because after changing back to 8080 m:8080 it worked!!’

I am trying to figure out how to make the container connect to the internet. I found some info but I started containers 1 week ago😅.

-p 8080:80 for example how does improve the situation. Is it that for getting network acces it isn’t possibly by command run?

Also for the error I am thinking was this ~before the folders. What is it exactly? After trying out from the homeasistant command line, now it does write and build the container.

So i think I figured most parts out. Thanks!!!

podman run --name openhab --cap-restart=unless-stopped -p 8080:80 -v /etc/localtime:/etc/localtime:ro -v ~/opt/openhab/openhab_addons:/openhab/addons -v ~/opt/openhab/openhab_conf:/openhab/conf -v ~/opt/openhab/openhab_userdata:/openhab/userdata --pull=always openhab/openhab:3.3.0

After running the openhab demo.
Some documents where place in some folder but now it says i can’t remove because i do jot have priffiliged to remove the folders. Not sure how to remove the privileges.

Let me know:)

Ultimately these are all question you can and should get from the Docker and Podman docs. They are not related to OH at all. If you choose to use a non-supported configuration and way to run OH, it’s up to you to know and understand what you are doing or seek help on a forum for Docker and Podman. You could start with docker run | Docker Docs.

Whether or not you want to take the time to learn Podman and Docker is, frankly, not our problem. We here are openHAB experts, not Docker or Podman experts. We have nearly a dozen supported and documented ways to install and configure OH. Podman is not one of them, but Podman does generally follow Docker. See Docker | openHAB for the docs showing how to run in Docker and see what might translate.

At a high level


That’s the command to Docker to mount the given folder on the host machine into the container at the given location.

It tells Docker that the volume is exclusive to that container and not shared to another container.

Tells the container to run as root. Usually you do not want to do that. But the fact that the error went away really points at your host not having a UID 9001 and/or the volumes mounted to the container do not have permissions that allow it to read/write/modify those directories.

Runs the container in the background.

When you want the program to continue running even after you log out.

Because it’s running in the background. You have to use the docker logs command to see it’s logs.

Because openHAB is failing to start in the first place.

It adds the CAP_NET_RAW and CAP_NET_BIND_nSERVICE to the container. What does that mean? :person_shrugging: None of us here are Docker nor Podman experts. But the Docker docs like have stuff to say about it.

What makes you think that would work in the first place? openHAB is a completely different program with completely different needs and expectations. Would you expect to be able to copy a command you’d run on a Mac and have it work on Windows? Same thing. You need to use the command and arguments as outlined in the openHAB docs.

Because it kept failing to start.

Docker docs should explain that.

You can’t just choose a random port. The first number is the port to expose to the world and the second number is the port used by container. You can’t just randomly choose the second number and the -p option is pointless when using --net=host.

Please review the docs for Docker. You are spending a lot of your own time as well as using the time of everyone here struggling with things that are not even openHAB related and which have answers in the Docker docs, Podman docs, and numerous publicly available tutorials online.

We’ve already explained several times and from several users on this thread. Once again.

  1. Linux implemented discretionary access controls. This means the owner of a file (or root) grants which other users have access to read, write, and execute files.
  2. openHAB runs inside the container as user 9001 with a group 9001 (unless otherwise told to run as something else, see the docs).
  3. When the container starts, all the ownership and permissions of the mounted volumes are changed to be owned by 9001:9001 and only user 9001 has permission to write to the files.

If you don’t have a 9001 user on your host, you don’t have any user on the host except root that can write to those files.

That’s super basic Linux. If you struggle with basic Linux, please go through some basic Linux tutorials. If you don’t know basic Linux you are unlikely to ever be successful using Docker or Podman. You might eventually stumble into something that works but it will be brittle. At some point something weird will happen and you’ll be loss to fix it.

I highly recommend instead of trying to run OH in Docker on Podman, that you get started running OH on a more familiar operating system, or, as the docs recommend, use openHABian on an RPi which handles all this stuff for you and all you need to worry about, at least at first, is openHAB itself.

From an openHAB context, this argument is nonsense. There is nothing inside the container using port 80. As the docs recommend use --net=host instead.

Thanks for you’re reply and everybody else!
I wil try these options everybody said and see if I can make it happen:)

I wil indeed look for a more suited environment for my podman (docker) commands questions.

Why is mine way of using openhab not supported if i may ask?
Openhab container?

I did not find any podman forum to ask these questions so I just dropped some questions at some forums to get some help and only here there were helpful. From my understanding podman and Docker work the same but also they are not the sameđŸ€Ș some commands are the same and some not.

There was a kind of hurry because I promised my wife that it would work fast again:) I have used jung sv server for a while for knx but it is just not reliable to use. Connection tru a server in germany takes evertime to long or on android it doesn’t connect and we have to reapply the password again for the user because we removed the cashe. Knx and tasmota knx works perfect but now i want to move to knx and mqtt for more reliability. So then I started a server with home assistant and openhab to replace the jung server:)

Thanks again for youre detailed explanation!!
And apologies for my topic that is not related to openhab fully. Thanks for the support! I will try these options tonight when i get back from holiday​:sunglasses::raising_hand_man:

There is a slight difference between “not supported” as in it won’t work and “we don’t support it” meaning it’s a way to run OH that is relatively uncommon so we can’t do much to help. Running the OH container in Podman is the latter.

Hello Bluegar,

When I try to run you’re command line I am getting the following error:

Error: statfs /opt/openhab/.java: no such file or directory

I stil made the folders but still getting this error.
That’s why I don’t understand.

I was also wondering why this command starts with

/usr/bin/podman

Thanx for helping!

Hi,

from your first comment it seems your host folders are not in /opt/openhab but in ~/opt/openhab thus you may want to adjust this?
What also may help:

  1. Create user openhab:openhab as 9001:9001 on the host system
  2. Switch ownership of the openhab folders to this new user / group (it helps if your normal user is also assigned to group openhab / 9001 such that you can easily access the files)
  3. remove existing container (docker rm ) to start freshly
  4. if you do not have relevant content in your openhab folders, I would also clean these up

Then start new instance of the container and see what happens :slight_smile:

rfu