Centos7.x 执行 docker 时报如下错误
出现以下错误

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

Cannot connect to the Docker daemon at tcp://localhost:2373. Is the docker daemon running?

错误时

配置 DOCKER_HOST

sudo vim /etc/profile.d/docker.sh

内容如下

export DOCKER_HOST=tcp://localhost:2375 

应用

source /etc/profile
source /etc/bashrc

配置启动文件

sudo vim /lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd

修改为

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:7654

2375 是管理端口
7654 是备用端口

重载配置和重启

sudo systemctl daemon-reload 
sudo systemctl restart docker.service

查看

docker version

输出

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:20:16 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:23:58 2018
  OS/Arch:      linux/amd64
  Experimental: false

思路来源
https://blog.csdn.net/u010046908/article/details/79553227

Logo

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

更多推荐