eth-educators / eth-docker

Docker automation for Ethereum nodes
Apache License 2.0
472 stars 221 forks source link

When running on WSL2 ethd fails to find docker.service #1961

Closed tkstanczak closed 4 days ago

tkstanczak commented 4 days ago

redacted:/mnt/c/src/eth-docker$ ethd logs -f --tail 50 Unit docker.service could not be found. The Docker daemon is not running. Please check Docker installation. "sudo systemctl status docker" and "sudo journalctl -fu docker" will be helpful.


Info from ChatGPT:

The reason docker.service does not appear in the list of services is that, in a typical WSL 2 environment, Docker is not managed by systemd. Instead, Docker Desktop for Windows manages the Docker daemon, and the integration with WSL 2 is done through the Docker Desktop application, not through a traditional systemd service.

Here's a more detailed explanation:

  1. WSL 2 Does Not Use systemd by Default: While your output shows that systemd is running in your WSL 2 environment (likely because you have enabled it manually), Docker itself in WSL 2 does not rely on a docker.service managed by systemd. Instead, Docker Desktop manages the Docker daemon from the Windows side.

  2. Docker Daemon is Managed by Docker Desktop:

    • In WSL 2, Docker Desktop starts and manages the Docker daemon.
    • When you enable WSL integration in Docker Desktop, it allows Docker commands to be executed within your WSL distributions, but the actual service (docker.service) is not managed by the WSL environment itself.
    • The Docker daemon runs as a process on the Windows side and communicates with your WSL environment through a special interface.
  3. How to Check Docker Status in WSL 2:

    • Instead of using systemctl, you can check the Docker daemon's status using:
      docker info
    • This command will give you information about the Docker daemon, including whether it is running and other configuration details.
  4. Why systemd Docker Service is Not Needed in WSL 2:

    • Since Docker Desktop provides the necessary integration, having a separate docker.service managed by systemd inside WSL 2 would be redundant and is not typically used.
    • The WSL 2 Docker integration allows Docker commands to be executed seamlessly without the need for traditional service management.

If you specifically need to run docker.service through systemd in WSL 2 (for testing or other specific needs), you would need to manually install and configure Docker inside the WSL distribution, separate from Docker Desktop. However, this setup is less common and not recommended when using Docker Desktop.

yorickdowne commented 4 days ago

I made a change that should account for this.

You are very likely the only user attempting to use Eth Docker on Windows. It should work but I'm not testing there.

There may be more gotchas: Ethstaker Discord is a good place to work through them.