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

版权声明:原创文章欢迎转载,不过要记得加出处哦 https://blog.csdn.net/wljk506/article/details/82290753

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

阅读更多

扫码向博主提问

风来了-

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • php
  • java
  • go
  • 架构
  • more
去开通我的Chat快问
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页