Skip to content

Instantly share code, notes, and snippets.

@jarrettgilliam
Last active July 10, 2023 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarrettgilliam/a20c7ddec721e25cffc94f78a11283a4 to your computer and use it in GitHub Desktop.
Save jarrettgilliam/a20c7ddec721e25cffc94f78a11283a4 to your computer and use it in GitHub Desktop.
Install docker in WSL2 using systemd
# References
# https://dev.to/klo2k/run-docker-in-wsl2-in-5-minutes-via-systemd-without-docker-desktop-28gi
# https://docs.docker.com/engine/install/ubuntu/
# Enable and start systemd
wsl.exe --update --web-download
wsl.exe -u root /bin/bash -c 'echo -e "[boot]\nsystemd=true" | tee /etc/wsl.conf'
wsl.exe --shutdown
wsl.exe /bin/bash -c 'systemctl --no-pager status user.slice &>> /dev/null && echo "OK: Systemd is running" || echo "FAIL: Systemd not running"'
# Install docker using the official convenience script
wsl.exe -u root apt-get remove docker docker-engine docker.io containerd runc
wsl.exe /bin/bash -c '/bin/bash <(curl -fsSL https://get.docker.com)'
# install portainer
wsl.exe docker volume create portainer_data
wsl.exe docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
# open the portainer management page
Start-Process https://localhost:9443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment