最近安装了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起不来,我删掉那个就好了。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐