Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker issues on WSL when Docker Desktop integration is disabled #181

Open
AaronFeledy opened this issue Jun 28, 2024 · 2 comments
Open

Comments

@AaronFeledy
Copy link
Member

AaronFeledy commented Jun 28, 2024

Do I have this issue?

  • If Lando can't seem to start Docker and executing docker version in your WSL session shows a message telling you to enable WSL integration in Docker Desktop, then you have this issue.

What's the workaround?

  • In Docker Desktop Settings > Resources > WSL Integration, enable integration for your WSL2 instance.
  • Start a fresh WSL shell so you get the updated configuration and start using Lando.

The problem

  • Windows binary paths are automatically included in a WSL instance's $PATH to allow executing a Windows exe from the WSL CLI.
  • Docker Desktop has a 'docker' binary that exists in the same directory as docker.exe. This is not the docker binary that is capable of executing commands. Instead it just echos a message telling you to enable Docker Desktop integration.
  • Because this "not actually docker" docker binary exists in $PATH, Lando perceives that Docker exists (which docker and which docker-compose?) during lando setup, so it skips installing it.
  • Lando subsequently can't start docker because the docker daemon doesn't exist.
  • Logs mislead by showing "systemd" errors as the likely cause because Lando is trying both the systemd and initd methods of starting services where systemd is not enabled on Debian-based WSL instances such as the Ubuntu default.

Repro

  • Install Docker Desktop for Windows.
  • Create a fresh WSL instance (or make sure the "docker" user group doesn't exist)
  • In Docker Desktop Settings > Resources > WSL Integration, disable integration for your WSL2 instance.
  • In the WSL instance:
    • Run lando setup
    • Notice lando setup does not attempt to install docker and also fails to add the user to the "docker" group
    • Notice subsequent lando commands fail to start docker (because it doesn't exist, but the user doesn't know that)
    • Be mislead by "systemd" errors in logs as the only clue as to why docker didn't start.

Suggested Fix

  • Improve the existing WSL/Docker Desktop detection to include this scenario.
  • Improve lando setup so that it doesn't report that Docker is already installed in this scenario.
  • If possible, try to enable the WSL integration in Docker Desktop during lando setup because Docker recommends using Docker Desktop WSL integration vs installing docker directly.
  • If automatically enabling WSL integration is not possible, we should fail with an error telling the user to enable it and restart their shell.
@pirog
Copy link
Member

pirog commented Jun 28, 2024

@AaronFeledy my take on this, FWIW, is that it's probably not great to force on a setting a user has purposefully disabled.

I feel like it would be best to improve lando so that the usual linux docker setup runs in WSL2 when the integration is disabled?

@AaronFeledy
Copy link
Member Author

AaronFeledy commented Jun 28, 2024

@pirog Yeah, picking the best default behavior gets tricky:

If they have Docker Desktop installed, they probably are already using it and want to continue using it. It's what's recommended by Docker and should probably also be our recommendation.

It's easy to get into a situation where the integration was never enabled for your WSL instance, even if you want it (or don't know you want it) such as when creating a WSL instance that is not marked as the default. (DD only enables integration for the default WSL instance).

I've had issues where I've had docker installed inside a WSL instance and then later indirectly enabled DD integration by telling WSL to start considering it my default instance. Then you get inconsistent behavior because starting Docker Desktop will symlink the integration bins into your WSL instance only while Docker Desktop is started. If you haven't started Docker Desktop yet that day or it crashes, the docker you installed inside the instance gets used instead. My concern is that if a user doesn't know the how/what/why of the integration, we may unintentionally create problems for them.

If the user is actually trying to keep things separate (often mistakenly thinking there's a performance benefit) and has deliberately chosen to disable the integration, then we could install docker. I don't think we can automatically determine their intent though. I think this is an advanced use case and there are WSL-specific ways to disable interoperability if their goal is to actually keep things separated. In which case, Lando setup won't see Docker Desktop and will just install it as expected.

Perhaps we can recommend the Docker Desktop integration approach but also add a flag to the lando setup command that allows them to signal their intent and force the docker install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants