Docker WSL连接windows 服务器问题

Docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?


#Issues:服务器在windows上 安装的是WSL 上docker client。每次重启ubuntu都连不上服务器。

报错:annot connect to the Docker daemon. Is the docker daemon running on this host?

将WSL配置为连接到Docker for Windows

执行命令:export DOCKER_HOST=tcp://127.0.0.1:2375

现在执行docker命令不会再出现上面提示:
但是,该环境变量只会持续到会话结束。每次打开bash时都必须重新设置它。因此,为了避免这种情况,您需要在主目录中的一个名为.bash_profile或者 .bashrc的文件中设置该变量。
root用户的bashrc文件 位置在 /root
其他用户的bashrc文件 位置在 /home/用户名/

打开这两个文件中有数据的那个并在结尾处添加:
export DOCKER_HOST=tcp://localhost:2375
(docker for windows 的设置的General里面 Expose daemon on tcp。。。。。要选)

其他用户 要添加到docker的用户组中去

创建docker组
sudo groupadd docker

将当前用户加入docker组
sudo gpasswd -a ${USER} docker

重新启动docker服务
sudo service docker restart

当前用户退出系统重新登陆
su root
su 要添加的用户

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值