To fix this, you can run sudo visudo -f /etc/sudoers.d/passwordless_docker_start, add the following to the file (replacing username with your Linux username), save and close. Now this has the annoying side effect of making you have to type out your sudo password whenever you start WSL2 for the first time. If you don't want to have to remember and invoke that command every time, you can add the following to your "~/.profile", or your shell configuration file like "~/.bashrc": if then The simple but annoying solution is to run sudo service docker start whenever you want to use Docker. One hiccup with docker in WSL2 is that it doesn't automatically start the Docker service. Configuring Docker on WSL2 Using Docker Without Invoking Rootĭon't want to have to run docker commands with sudo all the time? Follow this guide to add yourself to the docker group. Stop before running sudo docker run hello-world. Install Dockerįollow these setup instructions (if you chose to install a distro other than Ubuntu, find the appropriate install guide on the left of that page). Do package updates, install whatever tools and packages you want, and just generally make yourself at home. Now, open the "Ubuntu" application that you just got installed, and set your username and password. If you're having trouble upgrading the distro, see here for help. # Check that the distro you installed is version 2 Make sure that the distro you just installed is a WSL2 distro, as you can't run docker in WSL1. Make sure you install a WSL2 distro.įor the rest of this, I'm assuming you've installed the default Ubuntu Distro, steps might be slightly different for other distros. If that doesn't work, or you want to fiddle/customize/use a non-default distro, check out Microsoft's guide here. Nowadays, this should be as simple as Win+X, selecting (Admin), and running wsl -install. Here's the quick and dirty way to get that set up: Install WSL Say you want to run a Linux environment on a Windows machine, and in that environment one of the things you want to do is make use of docker containers. But if you find yourself in a position where you can't or don't want to use the Docker Desktop support, read on. This obviates the need to install Docker within a WSL2 distro in most cases. Previous Post: How to Communicate with an Arduino from Docker Next Post: Introducing DM's Log: SupplementalĮdit: It's come to my attention that, since I figured out this workaround back when WSL2 and thus Docker's WSL2 backend were new, Docker Desktop for Windows has added support for using Docker from within your WSL2 distro.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |