Windows10内置Linux子系统(WSL)设置服务自启
WSL 启动时运行任何服务的首选方式取决于 Windows 版本
Windows 11
在/etc/wsl.conf文件添加命令
[boot]
command="service docker start"
Windows 10
在wsl linux目录的~/.bash_profile文件添加命令
service docker start
这里有个问题,在添加了~/.bash_profile文件后,~/.bashrc会失去效果,这是因为在添加~/.bash_profile之后,~/.profile会被覆盖不再运行。
解决方法:
- 方案一:将
~/.bash_profile中的脚本命令移至~/.profile,并删除~/.bash_profile。 - 方案二:在
~/.bash_profile中添加source ~/.profile。

浙公网安备 33010602011771号