2

I work on a server (Ubuntu 20.04 LTS (GNU/Linux 5.4.0-40-generic x86_64)). Somebody else set-up some folders and mysql data bases in a docker redcap-lamp on this server. In addition, he created a user account for me to enter the server, and the docker.

Every thing works fine with my account.
As login on the server I use: ssh [my user account]@[our server].
To enter the docker I (was told to) use: docker exec -it redcap-lamp bash.

I now had to create a user account for somebody else (and am not used to working in terminals and dockers).

I created a new user account by using: sudo adduser [newUser], what worked fine. It is possible to log in with this new account to have access to our server. Unfortunately, when I use docker exec -it redcap-lamp bash to enter the docker with the new account, the permission is always denied. I get the output:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/redcap-lamp/json: dial unix /var/run/docker.sock: connect: permission denied

Do I have to give new users some 'privileges' or something? Does anybody know where the problem lies and how it can be fixed?

wibeasley
  • 5,000
  • 3
  • 34
  • 62
danielsmith
  • 63
  • 1
  • 4

2 Answers2

2

You need to add the new username in the docker group:

sudo usermod -a -G docker <newUser>

Check if the user was added:

cat /etc/group | grep docker

Log as the new user and check if you still face the problem
Neo Anderson
  • 5,957
  • 2
  • 12
  • 29
  • I'm glad I could help. You may accept / up-vote if the answer if it was accurate and answered your question, to help other users that have similar issues. Thanks! – Neo Anderson Jul 24 '20 at 11:31
  • As stated in my answer: Be carefull as it will increase your attack surface on your Docker daemon. – Michée Lengronne Jul 29 '20 at 10:44
0

You need to create a docker group and add the user to it https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user

Warning: It will increase your attack surface. As you are new to docker, I advise you to take info about the risks from the Somebody else if possible.

  • Thanks, I still don't understand, why I need to enable my user to enter the docker. Since I created the user by using: ```sudo adduser ...```, I thought my user has admin privileges...? Or have I misunderstood something? – danielsmith Jul 24 '20 at 11:32
  • `sudo adduser` creates a basic user. It does not have any particular permissions. You add permissions afterward by puting this user in groups. `sudo` means that you use `root` to create the user but not that the user behaves as root. – Michée Lengronne Jul 24 '20 at 13:08