permission docker

Hello,

I am using HestiaCP on my server and trying to deploy my application using Docker.

The problem is that the admin user does not have permission to run Docker commands. For example, when I try to run:

docker compose build

I get the following error:

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
dial unix /var/run/docker.sock: connect: permission denied

I tried to add the admin user to the docker group using:

usermod -aG docker admin

but I get:

usermod: Permission denied.
usermod: cannot lock /etc/passwd; try again later.

It seems the admin user does not have permission to modify system groups or use sudo.

What is the recommended way to deploy Docker applications on a server with HestiaCP?

Should Docker be managed only by the root user, or is there a proper way to give the admin user access to Docker?

Thanks in advance for your help.

Hi,

No, it doesn’t have perms to do so, it also doesn’t have perms to run Hestia commands and that’s a security measure.

You must use root user to add user admin to docker group.

I would manage docker only using the root user, adding admin user to docker group will give too much perms to that user.

Alternatively, you could use Podman instead of Docker. Podman is rootless, so the admin user could use the container without root privileges but it also has some drawbacks, such as not being able to use ports below 1024 (but this shouldn’t be a problem is you are accessing the container using Nginx as a proxy).

3 Likes