Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Docker on Debian 12 : Exception: Use sudo to read '/dev/nvme0' SMART data #45

Open
deepcoder opened this issue May 7, 2024 · 4 comments

Comments

@deepcoder
Copy link

Under docker, even if I sudo docker run, I receive the following error for the disk info.

Linux yippie-ha 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux

[2024-05-07 17:43:14,103] ERROR Use sudo to read '/dev/nvme0' SMART data
[2024-05-07 17:43:14,103] INFO mqttc.publish('psmqtt/yippie-ha/smart/nvme0/temperature/error', 'Use sudo to read '/dev/nvme0' SMART data')
[2024-05-07 17:43:14,103] ERROR run_task caught: smart/nvme0/temperature : Use sudo to read '/dev/nvme0' SMART data
Traceback (most recent call last):
  File "/opt/psmqtt/src/task.py", line 154, in run_task
    payload = get_value(task)
              ^^^^^^^^^^^^^^^
  File "/opt/psmqtt/src/handlers.py", line 802, in get_value
    value = handler.handle(tail)
            ^^^^^^^^^^^^^^^^^^^^
  File "/opt/psmqtt/src/handlers.py", line 536, in handle
    raise Exception(errmsg)
Exception: Use sudo to read '/dev/nvme0' SMART data

Thank you for your work and help!

@f18m
Copy link
Collaborator

f18m commented May 7, 2024

hi @deepcoder ,

Under docker, even if I sudo docker run, I receive the following error for the disk info.

Using 'sudo docker run' is not doing what you think probably.
The 'docker' program is just a client for the dockerd server which runs as a daemon in background.
The 'docker' client is just asking the server to start a new container when you use 'docker run'. Doing that with root permissions does not mean that the new container will be started by the server with root permissions.
To do that, you should be using 'docker run --privileged'.
This is mentioned in the README at https://github.com/eschava/psmqtt?tab=readme-ov-file#deploy-with-docker
Can you retry with --privileged?

@deepcoder
Copy link
Author

deepcoder commented May 8, 2024

I was using the 'privileged' in both my non sudo and sudo attempts, as per your documentation. Both throw the same error. The docker commands I tried are listed below. FYI, trying to use ":latest" for the image threw a different error and would not start container, so I hard coded the v1 image version.

docker run -d -v /home/user/psmqtt/psmqtt.conf:/opt/psmqtt/conf/psmqtt.conf \
   --privileged --hostname $(hostname) \
   ghcr.io/eschava/psmqtt:latest


docker run -d -v /home/user/psmqtt/psmqtt.conf:/opt/psmqtt/conf/psmqtt.conf \
   --name="psmqtt-1.0.0" \
   --privileged --hostname $(hostname) \
   ghcr.io/eschava/psmqtt:1.0.0

@f18m
Copy link
Collaborator

f18m commented May 9, 2024

I was using the 'privileged' in both my non sudo and sudo attempts, as per your documentation. Both throw the same error. The docker commands I tried are listed below. FYI, trying to use ":latest" for the image threw a different error and would not start container, so I hard coded the v1 image version.

docker run -d -v /home/user/psmqtt/psmqtt.conf:/opt/psmqtt/conf/psmqtt.conf \
   --privileged --hostname $(hostname) \
   ghcr.io/eschava/psmqtt:latest

You're right the 'latest' tag is not being pushed.
FYI I have an issue open on the github action project: mr-smithers-excellent/docker-build-push#238

docker run -d -v /home/user/psmqtt/psmqtt.conf:/opt/psmqtt/conf/psmqtt.conf
--name="psmqtt-1.0.0"
--privileged --hostname $(hostname)
ghcr.io/eschava/psmqtt:1.0.0

This one however should really work. Can you run 'sudo smartctl --scan' (outside of any docker container) and paste the output here?

@f18m
Copy link
Collaborator

f18m commented May 15, 2024

ping @deepcoder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants