Skip to content

Instantly share code, notes, and snippets.

@stephenchew
Created April 24, 2023 06:41
Show Gist options
  • Save stephenchew/b53241cf568feda83c2b753c7bd43e8d to your computer and use it in GitHub Desktop.
Save stephenchew/b53241cf568feda83c2b753c7bd43e8d to your computer and use it in GitHub Desktop.
Docker start-up script for WSL2
./start-docker.sh
#######################################################################################################################################
# Inspired by https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9#launch-script-for-raw-dockerd-endraw- #
#######################################################################################################################################
#!/bin/bash
DOCKER_DISTRO=Ubuntu-22.04
docker ps >/dev/null 2>&1 && DOCKER_RUNNING=1 || DOCKER_RUNNING=0
if [ $DOCKER_RUNNING == '0' ]
then
echo 'Starting docker...'
/mnt/c/Windows/System32/wsl.exe -d $DOCKER_DISTRO sh -c "nohup sudo -b dockerd < /dev/null >/dev/null 2>&1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment