wsl2上用docker部署运行环境,mvn构建镜像找不到dockerhost

项目构建过程参考:https://macrozheng.github.io/mall-learning/#/ 中的linux下docker构建

 

在docker上搭建网站服务,设置了docker.service的execStart,添加tcp//:0.0.0.0:5375之后,mvn构建一直失败,说连不上本地的5375端口。

纠结了非常久才找到解决方法,其实之前在配置registry的时候曾经配置过,只不过搞不懂这个是什么意思,没想到还有这个方法。

参考https://www.jianshu.com/p/c7bc8fa1ee5f

vim /etc/profile
export DOCKER_HOST=tcp://0.0.0.0:5375
#刷新配置
source /etc/profile
#验证tcp
docker -H tcp://localhost:5375 images

docker -H tcp://127.0.0.1:5375 images

docker -H tcp://0.0.0.0:5375 images


  

如果还有报错连接不上,参考https://www.jianshu.com/p/7c0084fd9003 的第一个方法

 vi /etc/docker/daemon.json 

{
  "registry-mirrors": ["https://kf0vxqi6.mirror.aliyuncs.com"],
  "hosts": [
        "tcp://0.0.0.0:5375",
        "unix:///var/run/docker.sock"
    ]
}

  

 

posted @ 2020-02-21 11:57  头鹰在学习  阅读(648)  评论(0编辑  收藏  举报