docker / docker-install

Docker installation script
https://get.docker.com
Apache License 2.0
2.45k stars 782 forks source link

What is the reason for WSL2 not being supported ? #412

Open advnpzn opened 6 months ago

advnpzn commented 6 months ago

I've tried running the script to install docker in WSL2 (Debian bookworm) and I got the following warning.

curl -fsSL https://get.docker.com/ -o get-docker.sh
# Executing docker install script, commit: e5543d473431b782227f8908005543bb4389b8de

WSL DETECTED: We recommend using Docker Desktop for Windows.
Please get Docker Desktop from https://www.docker.com/products/docker-desktop/

You may press Ctrl+C now to abort this script.
+ sleep 20

But I've modified the script locally to make is_wsl() throw a false.

is_wsl() {
    case "$(uname -r)" in
    *microsoft* ) false ;; # WSL 2
    *Microsoft* ) false ;; # WSL 1
    * ) false;;
    esac
}

And I was able to install docker in my Debian bookworm WSL2. And it is even working perfectly fine.

wsl --version
WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3447

I want to know why installing Docker in WSL2 is not supported and what issues do we face if someone installs Docker in WSL ?

linghengqian commented 2 months ago

WSL DETECTED: We recommend using Docker Desktop for Windows. Please get Docker Desktop from https://www.docker.com/products/docker-desktop/

You may press Ctrl+C now to abort this script.

Server: Docker Engine - Community Engine: Version: 27.2.1 API version: 1.47 (minimum version 1.24) Go version: go1.22.7 Git commit: 8b539b8 Built: Fri Sep 6 12:08:10 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.22 GitCommit: 7f7fdf5fed64eb6a7caf99b3e12efcf9d60e311c runc: Version: 1.1.14 GitCommit: v1.1.14-0-g2c9f560 docker-init: Version: 0.19.0 GitCommit: de40ad0

================================================================================

To run Docker as a non-privileged user, consider setting up the Docker daemon in rootless mode for your user:

dockerd-rootless-setuptool.sh install

Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.

To run the Docker daemon as a fully privileged service, but granting non-root users access, refer to https://docs.docker.com/go/daemon-access/

WARNING: Access to the remote API on a privileged Docker daemon is equivalent to root access on the host. Refer to the 'Docker daemon attack surface' documentation for details: https://docs.docker.com/go/attack-surface/

================================================================================

linghengqian@DESKTOP-2OCN434:/tmp$

linghengqian commented 2 months ago

echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y sudo groupadd docker sudo usermod -aG docker $USER newgrp docker

Changed to use local of log-driver

sudo vi /etc/docker/daemon.json

sudo systemctl restart docker docker run hello-world


- I would say that Docker Desktop cannot be installed directly under WSL, refer to https://github.com/ubuntu/WSL/issues/486 . Docker Desktop can only be installed in a Windows Native environment.
advnpzn commented 2 months ago

I observed this git from https://learn.microsoft.com/zh-cn/windows/wsl/tutorials/gpu-compute . But in reality, the script just intentionally does nothing for 20 seconds. The script does not block the installation.

Wow, I guess I shouldn't have just assumed that after the 20 secs delay, it would just exit.