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

最近安装了Docker ,在使用最简单的"docker run hello-world",则出现问题,报错

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

查询了网上,都主要说Docker没起来,输入

sudo service docker start
#不过我这里还是报错,
out:docker: unrecognized service

最后各种卸载重装,甚至是Deb文件,都不行,最后使用了菜鸟docker安装

执行了

wget -qO- https://get.docker.com/ | sh

#然后下面是输出
# Executing docker install script, commit: 2f4ae48
Warning: the "docker" command appears to already exist on this system.

If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.

If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.

You may press Ctrl+C now to abort this script.
+ sleep 20
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null
+ sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu trusty stable" > /etc/apt/sources.list.d/docker.list
+ sh -c apt-get update -qq >/dev/null
W: Duplicate sources.list entry https://download.docker.com/linux/ubuntu/ trusty/stable amd64 Packages (/var/lib/apt/lists/download.docker.com_linux_ubuntu_dists_trusty_stable_binary-amd64_Packages)
W: You may want to run apt-get update to correct these problems
+ [ -n  ]
+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
+ sh -c docker version
Client:
 Version:           18.06.3-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        d7080c1
 Built:             Wed Feb 20 02:27:13 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.3-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       d7080c1
  Built:            Wed Feb 20 02:25:38 2019
  OS/Arch:          linux/amd64
  Experimental:     false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

最后再执行

 docker run hello-world

成功,发现安装的是18.06.3-ce版本,不是最新的18.09.6-ce,估计原来是版本太新引起的

PS:最后发现是我把 /etc/docker/daemon.json这个文件里放了很多人建议的阿里云镜像源,可能格式有问题,所以docker起不来,我删掉那个就好了。

  • 4
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 8
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值