Reputation: 21
When I access my container:
jenkins@bc145b8cfc1d:/$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
jenkins@bc145b8cfc1d:/$ whoami
jenkins
jenkins@9cdb24cf71f2:/$ usermod -G users jenkins
ERROR : usermod: Permission denied.**
Upvotes: 2
Views: 2328
Reputation: 5767
You can execute a bash command inside a container as a different user. In this case you can run from your host:
docker exec -it --user root <container id> usermod -G users jenkins
or you can enter the container interactively and execute any commands as root as follows:
docker exec -it --user root <container id> bash
and then:
root@9cdb24cf71f2:/$ usermod -G users jenkins
Note: The solution above assumes that the group users
exists.
Upvotes: 1