Exec under docker

docker
exec
Tags: #<Tag:0x00007f1e574e6980> #<Tag:0x00007f1e574e6840>
(Ahiel) #1

Hello,
I’m trying to move my openhab to docker, and having problem with the exec binding.
I’ve mounted volume to directory with jar to run some logic and exec some logic.
In my raspberry the logic works great, in the docker I don’t see any errors in the log but the process not run… (no mq update) if I’m running it inside the docker (login to the container using bash) it is working…
any ideas why?

Thanks ahead.

0 Likes

(Rich Koshak) #2

Since you can run it from bash inside the container then follow How to solve Exec binding problems.

One thing to note is when you run docker exec -it openhab /bin/bash you get a shell as root, not the openhab user.

0 Likes

(Ahiel) #3

I’ve tried, the echo command is working great… but still the java run program not running, the result of the exec is null…
I’ve tried to specific the location…
this is the command:
executeCommandLine("/usr/bin/java@@-jar@@/home/me/calc-mqtt.jar",60000)

0 Likes

(Rich Koshak) #4

Does it take longer than a minute to run normally?

Does it take longer than a minute for the call to executeCommandLine to run or does it return immediately?

What are the permissions on the jar file?

I’ve only ever seen executeCommandLine return null when the command didn’t finish before the timeout.

0 Likes

(Ahiel) #5

Now I see its permissions issues.
but as far as I see:
result is: Error: Unable to access jarfile /home/me/calc-mqtt.jar

how can I set permission to the file? the permissions is:
-rwxrwxrwx 1 9001 9001

0 Likes

(Rich Koshak) #6

It might be the case that Docker will not allow you to execute a file mapped into the container. I don’t know if that is the case but if it is that would be an awesome security feature.

0 Likes

(Ahiel) #7

I’ve found out the problem.
I had to login into the container and add permissions to /home/me directory…
I don’t understand why since I set the permission of the directory from the docker machine to 777…
any way to change it already when I’m creates the docker?
(using docker run command?)

0 Likes

(Rich Koshak) #8

You would have to rebuild the container to make the change when the image is created or modify the entrypoin.sh script to do it for you. Both require modifications to the Dockerfile.

0 Likes