Is it really ok to run pip3 as root?

Hi!
I have a question about how pip3 should be used. Often I hear and read that pip3 should only be executed as a user or in a virtual environment and never be executed as root.

If I would like to monitor docker in Checkmk I know that I need to run:
“pip3 install docker” on the host so that the checkmk-plugin can talk to the docker deamon.

What I don’t understand is why it is recommended in the Checkmk-docs to run “pip3 install docker” as root?

If you run:
sudo -H -s
pip3 install docker

You will see the following: “WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager.”

I know that you can disable this warning but that seems to be a not so optimal solution.

The recommendations seems to be to run pip3 as a user or in a virtual environment and not as root. Can someone explain to me why the Checkmk-docs recommends running “pip3 install docker” as root?

Is it because the checkmk-agent can’t communicate with the docker-library for python if it is not installed by the root user or something?

Best regards

Honestly, a slightly better way to go would be trying to install the system docker Python module first and using pip only if this fails:

sudo apt install python3-docker

We’ll discuss this in the documentation team and with our devs.

1 Like