GVKun编程网logo

【转载】Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docke...

14

对于想了解【转载】Docker安装后报CannotconnecttotheDockerdaemonatunix:///var/run/docker.sock.Isthedocke...的读者,本文将提

对于想了解【转载】Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docke...的读者,本文将提供新的信息,并且为您提供关于Cannot connect to the Docker daemon、Cannot connect to the Docker daemon at tcp://xxx.xx.x.x:2376. Is the docker daemon running?、Cannot connect to the Docker daemon at unix、Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?的有价值信息。

本文目录一览:

【转载】Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docke...

【转载】Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docke...

Docker Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 解决办法

白纸  ・ 2017 年 07 月 20 日 ・最后由 rocl 回复于 2017 年 12 月 26 日 ・9781 次阅读

问题
刚在新的 Centos 上安装 Docker-CE, 后运行 docker run hello-world 报错 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

解决办法
$ systemctl daemon-reload
$ sudo service docker restart
$ sudo service docker status (should see active (running))
$ sudo docker run hello-world

 
转载文章时务必注明原作者及原始链接,并注明「发表于 TesterHome 」,并不得对作品进行修改。
共收到 4 条回复时间 点赞
 
孙高飞 #1 · 2017 年 07 月 20 日

你这是网管大法,直接重启。 好歹贴个 docker 的 log,分析一下到底是什么错误。

 
白纸 #2 · 2017 年 07 月 20 日 作者

@ycwdaaaa 就行 新安装 Docker 不行,看 github issues 撕了半天 也没撕出个所以然来,能力尚浅,分析不出来

 
lkx #3 · 2017 年 07 月 20 日

docker 客户端通过 unix:///var/run/docker.sock 与 docker daemon 通信,unix:///var/run/docker.sock 需要管理员权限才能访问,所以要么运行 sudo docker run hello-world,要么将当前用户添加在 docker 用户组中 
sudo usermod -aG docker $USER

 
rocl #4 · 2017 年 12 月 26 日

对的,lkx 正解,权限没加。关于这一点,docker doc 有明确提到

 

Cannot connect to the Docker daemon

Cannot connect to the Docker daemon

The error message "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" indicates that the Docker daemon is not running or not accessible.

To resolve this issue, you can try the following steps:

1. Check if the Docker daemon is running by running the following command:
   ```
   sudo systemctl status docker
   ```

   If it is not running, start the Docker daemon using the following command:
   ```
   sudo systemctl start docker

 

要关闭一个正在运行的 Docker 容器,可以使用以下命令:

```
docker stop <容器 ID 或容器名称>
```

将 `<容器 ID 或容器名称>` 替换为要关闭的容器的 ID 或名称。

例如,如果要关闭一个名为 `my-container` 的容器,可以运行以下命令:

```
docker stop my-container
```

Docker 将发送一个停止信号给容器,然后容器将停止并退出。

如果您想要立即停止容器而不等待它正常退出,可以使用 `docker kill` 命令:

```
docker kill <容器 ID 或容器名称>
```

这将立即停止容器,类似于强制终止它。

请注意,这些命令需要在具有足够权限的用户或使用 `sudo` 命令下运行。

Cannot connect to the Docker daemon at tcp://xxx.xx.x.x:2376. Is the docker daemon running?

Cannot connect to the Docker daemon at tcp://xxx.xx.x.x:2376. Is the docker daemon running?

一.问题描述

   在用docker部署jenkins实现自动化部署服务时,报错:

二.问题分析:

   经前辈讲解得知,需要在Jenkins里面运行docker,而docker分为客户端和服务端,普通的docker命令由客户端操作,但客户端需要连接到服务端,而此时Jenkins是一个单独的容器,可以看做一个单独的系统,它不知道docker是谁,所以需要把docker映射进去了,但是我们映射的只是客户端,所以需要指定它连接到宿主机的服务端。在jenkins配置的docker也是客户端。

三.问题解决:

  在运行jenkins时,挂载所需的环境,在用docker-compose运行时,可以直接在docker-compose.yml添加相应的映射环境

 environment:
    DOCKER_HOST: tcp://xx.xx.xx.xx:2376

然后在储存驱动修改映射


{
  "hosts": [
        "tcp://xx.xx.xx.xx:2376",
        "unix:///var/run/docker.sock"
    ]
}

挂载相应文件目录

需要注意的是,上述映射的ip是jenkins所在的ip,因为jenkins是用户

Cannot connect to the Docker daemon at unix

Cannot connect to the Docker daemon at unix

记录一次宕机。

服务不可用,登录Linux,尝试重启docker容器,报:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?错误。

查看磁盘占用

df -h

100%占用。

定位到具体文件夹

du -sh *|sort -hr

发现是一个日志文件达到了惊人的35G...

是的,35G,前菜狗后端看来比预期的还要菜。

清空日志文件

> xxx.log

重启Docker

systemctl daemon-reload
systemctl restart docker.service

服务恢复。

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

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

环境:centos7

问题:安装 docker 之后提示:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

解决:

systemctl daemon-reload
systemctl restart docker.service

 

今天关于【转载】Docker 安装后 报 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docke...的分享就到这里,希望大家有所收获,若想了解更多关于Cannot connect to the Docker daemon、Cannot connect to the Docker daemon at tcp://xxx.xx.x.x:2376. Is the docker daemon running?、Cannot connect to the Docker daemon at unix、Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?等相关知识,可以在本站进行查询。

本文标签: