I tried using wsl2, and it seems that Docker cannot be set to start automatically. It is troublesome to type the service command every time, so I considered it
Set to sudo so that users can start without a password
$ sudo visudo
# docker deamon auto up
User ALL=(ALL:ALL) NOPASSWD: /usr/sbin/service docker start
When stopped
$ service docker status
* Docker is not running
At startup
$ service docker status
* Docker is running
Added to start .bashrc only when docker is not running
$vim .bashrc
#Postscript
echo $(service docker status | awk '{print $4}') #Show startup status
if test $(service docker status | awk '{print $4}') = 'not'; then #State of standstill
sudo /usr/sbin/service docker start #Start-up
fi
With this setting, when entering wsl2, Docker will start if it is stopped.
Recommended Posts