Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active July 23, 2024 01:04
Show Gist options
  • Save rwcitek/f2b6fb5baddf16f6dc1f277a5d9f8366 to your computer and use it in GitHub Desktop.
Save rwcitek/f2b6fb5baddf16f6dc1f277a5d9f8366 to your computer and use it in GitHub Desktop.
Installing Docker on Windows without Docker Desktop

Installing Docker on Windows without Docker Desktop

WSL2 [1]

Newer versions of Windows

Open PowerShell with Admin rights and run wsl --install -d Ubuntu-22.04.

Older versions of Windows

  1. open Windows Features > check Windows Subsystem for Linux > Ok > Restart now
  2. open the Windows Store and install Windows Subsystem for Linux, if it isn't already installed
  3. open PowerShell with Admin rights and run wsl --install -d Ubuntu-22.04.

Install Docker [2]

Start an Ubuntu terminal.

# Become root
sudo su -

# Install Docker
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
sed -i -e 's/sleep 20/sleep 1/' /tmp/get-docker.sh
sh /tmp/get-docker.sh

# Enable iptables compatibility
echo 1 | update-alternatives --config iptables

# exit from being root
exit
# Add your user to the Docker group
sudo usermod -aG docker $USER

# Enable docker on startup
fgrep -q wsl.exe ~/.profile || {
cat <<'eof' >> ~/.profile

# check if docker is running
if grep -q "microsoft" /proc/version > /dev/null 2>&1; then
  if service docker status 2>&1 | grep -q "is not running"; then
    wsl.exe --distribution "${WSL_DISTRO_NAME}" --user root \
       --exec /usr/sbin/service docker start > /dev/null 2>&1
  fi
fi
eof
}

# close terminal window
exit
# open an Ubuntu terminal and run this command to confirm Docker works
docker container run --rm ubuntu:22.04 echo Hello, world

References

  1. https://www.tenforums.com/tutorials/46769-enable-disable-windows-subsystem-linux-wsl-windows-10-a.html
  2. https://nickjanetakis.com/blog/install-docker-in-wsl-2-without-docker-desktop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment