Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Docker Desktop work for multiple users? "ERROR: Docker Desktop is not running" while Docker is working properly

I'm using Docker on Mac and trying to open a project with Docker or Ddev. I have 2 users: admin and my user for work, who has no sudo rights. When I need to do something, that requires writing permissions, I just switch in the terminal to my admin user and execute all the commands from there. So, I'm logged into my working user and I'm trying to open a project(fin init for or ddev start) and I get that "ERROR: Docker Desktop is not running" text. What can I do with it?

like image 576
EvilArgest Avatar asked Oct 20 '25 10:10

EvilArgest


2 Answers

I think you'll find that Docker Desktop isn't really a multi-user app, and is never intended for that. You'll also find that DDEV isn't a multi-user app due to port conflicts.

The actual answer is: Install Docker Desktop for the user you want to use it.

A quick google shows this approach, which may work, of course it starts out with "First, be aware that docker is not designed to be securely shared among multiple users"

You may also want to try Colima, which is probably more generous about this, and is stored in separate users. But I would not be surprised if you can't run it with both users at the same time. See DDEV docs for colima.

like image 145
rfay Avatar answered Oct 21 '25 23:10

rfay


UPDATE:

After trying several approaches, it's impossible to run docker in two users simultaneously, but you can enable it on each user. I've added this to my .bashrc/.zshrc on each user.

alias enable-docker="sudo rm /var/run/docker.sock && sudo ln -s $HOME/.docker/run/docker.sock /var/run/docker.sock"

If I'm logged with User1 I just open the terminal and run enable-docker. When I finish using Docker with User1 I close it and switch to User2 session and run enable-docker.

OLD PROPOSAL: This will work one time.

Add export DOCKER_HOST=unix://$HOME/.docker/run/docker.sock to your .bashrc/.zshrc on your Mac and then source it or open a new terminal.

Credits

like image 23
Martin Forte Avatar answered Oct 22 '25 01:10

Martin Forte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!