Sudo systemctl start docker8/8/2023 ![]() Distributor ID: Ubuntu Description: Ubuntu 20. lsbrelease -a No LSB modules are available. ![]() It’s a bit of a hacky solution, but it’ll make starting the Docker daemon a bit easier. This is just a reminder to always enable docker service at system boot. You can even avoid to write a special start. This was a short post, explaining how to setup your WSL system to automatically start Docker when you open your terminal. You can avoid running a systemd daemon inside a docker container altogether. With the changes in effect, you should be able to run: docker run hello-worldĪnd see the hello-world from Docker. Logout and log back in (or open a new terminal) for all changes to take effect. echo '# Start Docker daemon automatically when logging in if not running.' > ~/.zshrcĮcho 'RUNNING=`ps aux | grep dockerd | grep -v grep`' > ~/.zshrcĮcho 'if then' > ~/.zshrcĮcho ' sudo dockerd > /dev/null 2>&1 &' > ~/.zshrcįinally, add your username to the docker group, so you don’t need to use sudo to run Docker commands. If you’re using bash (like most people), you’ll need to change. This can be done by adding the following lines to your profile. Now, we will update our profile file to automatically run the docker daemon if it’s not running yet. (replace nilfranadmin with your username, unless you want to give me access to your system □). Add the following line to the bottom: nilfranadmin ALL=(ALL) NOPASSWD: /usr/bin/dockerd We’ll want to allow our user to start dockerd without being prompted for a password. This will open your /etc/sudoers file, which controls how sudo command are executed. To do this without your command line prompting for passwords, run the following command: sudo visudo One way this can be done is to run the command to execute to Docker daemon at boot time via your profile file. With Docker installed, we’ll now need a way to run the Docker daemon automatically at boot time. ![]() In this post I’ll explore one way using which this can be done in WSL2 (and I assume this works for WSL1 as well, but I haven’t tested that).ĭetails of the system I’m running this on:Īutomatically start Docker daemon on WSL2įirst, you’ll need to install Docker. ![]() Since WSL2 doesn’t run systemd, you cannot use systemd to automatically start Docker as you typically would in a Linux system. However, one piece of nuisance for me has been that the Docker daemon doesn’t automatically start, and there’s no ‘easy’ way to start it automatically. I like running Docker containers in WSL2. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |