skip to Main Content

How can I allow a non-root user to run ‘docker exec’ ?

For example, I would like to allow a user to execute the following command without him obtaining root permissions to the whole system:
docker exec -it containerName /bin/bash

This command would allow him to get inside his ‘working environment’ and do whatever he wants…
It would be great to be able to allow this command to him, without password requests

The operating system is Ubuntu server

2

Answers


  1. Chosen as BEST ANSWER

    I probably found a solution to the problem.

    First of all I ran:

    visudo

    then I inserted a new line:

    studentxx ALL=NOPASSWD:/bin/docker exec -it containerName /bin/bash
    

    then the non root user (studentxx) is able to execute the following command without any problems

    sudo docker exec -it containerName /bin/bash
    

  2. Here’s something I found that seems to give a concise, step-by-step approach to what I’m deducting to be your problem. I will point out, though, that superuser is needed to prepare it.

    ~Roan

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search