rancher-desktop icon indicating copy to clipboard operation
rancher-desktop copied to clipboard

Revert docker socket after shutdown on Linux

Open dgiebert opened this issue 3 years ago • 2 comments

Preflight Checklist

  • [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

On Linux the/var/run/docker.sock gets replaced by a symlink to ~/local/share/rancher-desktop/lima/0/sock/docker but after the service is shutdown this symlink is not removed and therefore the host Docker System does not work anymore.

Proposed Solution

On Linux the easiest option is to implement a call to systemd and restart the docker.socket

Additional Information

Tested on Arch Linux using the AUR package

dgiebert avatar Feb 03 '22 08:02 dgiebert

Going to file this as a bug and get it into the backlog. Thanks for reporting it.

ericpromislow avatar Feb 03 '22 20:02 ericpromislow

This issue also affects macOS. Version 1.4.1 of Rancher Desktop leaves /var/run/docker.sock in an invalid state on macOS.

ashlineldridge avatar Jun 08 '22 21:06 ashlineldridge

After reviewing this issue, I don't think there is any need to "revert" the socket. Any daemon wanting to create a socket in this location will simply overwrite whatever is there already, both on Linux and macOS.

When you run Rancher Desktop with admin privileges (otherwise it doesn't have access to write /var/run/docker.sock) and the moby backend, it will create the socket on startup, regardless what is there already.

Even if you keep Rancher Desktop running, when you then start the docker daemon via Docker Desktop or systemctl, it will overwrite the socket. There is no need to stop Rancher Desktop or to remove the existing symlink.

Now, as for automatically starting the dockerd daemon when exiting Rancher Desktop, that should be done explicitly by the user. It is not at all clear that most users would want this behaviour.

It is kind of similar as if you have both Apache and nginx installed on your system, and both want to use port 80. If you stop nginx, it does not automatically start httpd; it is up to the user to decide if they want a server listening on that port, and which one.

There is one piece though that we do need to clean up (and currently don't):

When Rancher Desktop is run without admin privileges, it creates a rancher-desktop docker context and switches to it automatically, so docker commands will work.

When Rancher Desktop terminates, and the context is set to rancher-desktop, then it should switch it back to default (which means removing the currentContext setting from `~/.docker/config.json), so that the CLI will automatically use the default socket location again. This is currently only done by a "factory reset".

This issue can be closed once the resetting of the docker context has been implemented.

jandubois avatar Oct 11 '22 19:10 jandubois