[英]Docker can't connect to docker daemon
After I update my Docker version to 0.8.0
, I get an error message while entering sudo docker version
:在我将 Docker 版本更新为
0.8.0
后,我在输入sudo docker version
时收到错误消息:
Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
2014/02/19 12:54:16 Can't connect to docker daemon. Is 'docker -d' running on this host?
And I've followed the instructions and entered command sudo docker -d
, and I got this:我已经按照说明输入了命令
sudo docker -d
,我得到了这个:
[/var/lib/docker|2462000b] +job initserver()
[/var/lib/docker|2462000b.initserver()] Creating server
open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory[/var/lib/docker|2462000b] -job initserver() = ERR (1)
2014/02/19 12:55:57 initserver: open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory
How do I solve the problem?我该如何解决这个问题?
The Post-installation steps for Linux documentation reveals the following steps: Linux文档的安装后步骤揭示了以下步骤:
\nsudo groupadd docker须藤组添加泊坞窗
\nsudo usermod -aG docker $(whoami)sudo usermod -aG docker $(whoami)
\nsudo service docker start须藤服务泊坞窗启动
As Dayel Ostraco says is necessary to add environments variables:正如Dayel Ostraco所说,有必要添加环境变量:
docker-machine start # Start virtual machine for docker
docker-machine env # It's helps to get environment variables
eval "$(docker-machine env default)" # Set environment variables
The docker-machine start
command outputs the comments to guide the process. docker-machine start
命令输出注释以指导该过程。
To run docker daemon on Linux (from CLI ), run:要在 Linux 上运行 docker daemon(来自CLI ),请运行:
$ sudo service docker start # Ubuntu/Debian
Note: Skip the $
character when copy and pasting.注意:复制和粘贴时跳过
$
字符。
On RedHat/CentOS, run: sudo systemctl start docker
.在 RedHat/CentOS 上,运行:
sudo systemctl start docker
。
To initialize the "base" filesystem, run:要初始化“基本”文件系统,请运行:
$ sudo service docker stop
$ sudo rm -rf /var/lib/docker
$ sudo service docker start
or manually like:或手动像:
$ sudo docker -d --storage-opt dm.basesize=20G
docker-machine
on Linuxdocker-machine
To install machine binaries on Linux:在 Linux 上安装机器二进制文件:
locally:本地:
install -vm755 <(curl -L https://github.com/docker/machine/releases/download/v0.5.3/docker-machine_linux-amd64) $HOME/bin/docker-machine
global:全球的:
sudo bash -c 'install -vm755 <(curl -L https://github.com/docker/machine/releases/download/v0.5.3/docker-machine_linux-amd64) /usr/local/bin/docker-machine'
On macOS the docker
binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can't run Docker natively in OS X. So you have to install docker-machine
in order to create VM and attach to it.在 macOS 上,
docker
二进制文件只是一个客户端,你不能用它来运行 docker 守护进程,因为 Docker 守护进程使用 Linux 特定的内核特性,因此你不能在 OS X 中本地运行 Docker。所以你必须安装docker-machine
为了创建VM并附加到它。
docker-machine
on macOSdocker-machine
If you don't have docker-machine
command yet, install it by using one of the following methods:如果您还没有
docker-machine
命令,请使用以下方法之一进行安装:
brew install docker-machine docker
.brew install docker-machine docker
。 manually from GitHub :从GitHub手动:
install -v <(curl https://github.com/docker/machine/releases/download/v0.5.3/docker-machine_linux-amd64) /usr/local/bin/docker-machine
See: Get started with Docker for Mac .请参阅: Mac 版 Docker 入门。
docker-machine
on macOSdocker-machine
To start Docker Machine via Homebrew, run:要通过 Homebrew 启动Docker Machine ,请运行:
brew services start docker-machine
To create a default
machine (if you don't have one, see: docker-machine ls
):要创建
default
机器(如果您没有,请参阅: docker-machine ls
):
docker-machine create --driver virtualbox default
Then set-up the environment for the Docker client:然后为 Docker 客户端设置环境:
eval "$(docker-machine env default)"
Then double-check by listing containers:然后通过列出容器来仔细检查:
docker ps
See: Get started with Docker Machine and a local VM .请参阅: Docker Machine 和本地 VM 入门。
Alternatively to above solution, you can install a Docker app by:作为上述解决方案的替代方案,您可以通过以下方式安装 Docker 应用程序:
brew cask install docker
Check this post for more details .查看这篇文章了解更多详情。 See also: Cannot connect to the Docker daemon on macOS
另请参阅:无法连接到 macOS 上的 Docker 守护程序
If you are running Docker on OS X, running the following eval has worked for me.如果您在 OS X 上运行 Docker,运行以下 eval 对我有用。
eval "$(docker-machine env default)"
If you'd prefer not to have to run this eval statement on every terminal session, you can add this to your bash_profile
:如果您不想在每个终端会话上都运行此 eval 语句,您可以将其添加到您的
bash_profile
:
#Docker
eval "$(docker-machine env default)"
Be sure to restart the terminal session or run source on bash_profile
for the changes to take effect.请务必重新启动终端会话或在
bash_profile
上运行 source 以使更改生效。
After a detailed investigation, this issue seems to happen every time after Mac OS X is rebooted (or the Docker virtual machine is restarted) which prevents the Docker client from connecting to the Docker daemon.经过详细调查,这个问题似乎每次在 Mac OS X 重新启动(或 Docker 虚拟机重新启动)后都会发生,这会阻止 Docker 客户端连接到 Docker 守护程序。
To solve the issue, you can either:要解决此问题,您可以:
A) Reinstall Docker Toolbox using the official installer ( https://www.docker.com/products/docker-toolbox ), or simply A) 使用官方安装程序 ( https://www.docker.com/products/docker-toolbox ) 重新安装 Docker Toolbox,或者干脆
B) Run the following commands in order: B) 按顺序运行以下命令:
# First make sure that the virtual machine is running
docker-machine start default
# Regenerate TLS connection certs, requires confirmation
docker-machine regenerate-certs default
# Finally, set env
eval "$(docker-machine env default)"
C) Same as (B), you can also copy and paste the following line to run all of the three commands: C) 与 (B) 相同,您也可以复制并粘贴以下行以运行所有三个命令:
docker-machine start default; docker-machine regenerate-certs default; eval "$(docker-machine env default)"
In case you get the following error:如果您收到以下错误:
Error getting SSH command: Something went wrong running an SSH command!
command : cat /etc/os-release
err : exit status 255
output :
just re-run the three commands another time, and it should work the second time.只需再次运行这三个命令,第二次就应该可以工作了。
This usually happens when you are not in the docker
group.这通常发生在您不在
docker
组中时。 You can add yourself to the docker
group with:您可以通过以下方式将自己添加到
docker
组:
sudo usermod -aG docker yourusername
or要么
sudo usermod -aG docker $(whoami)
After this, you need to logout and log back into the server.在此之后,您需要注销并重新登录到服务器。
Alternatively, you can sudo
every Docker command.或者,您可以
sudo
每个 Docker 命令。
If all the other solutions above don't work you can try checking the ownership of /var/run/docker.sock
:如果上述所有其他解决方案都不起作用,您可以尝试检查
/var/run/docker.sock
的所有权:
ls -l /var/run/docker.sock
If you're not the owner then change ownership with the command:如果您不是所有者,请使用以下命令更改所有权:
sudo chown *your-username* /var/run/docker.sock
Then you can go ahead and try executing the Docker commands hassle-free :D然后你可以继续尝试轻松地执行 Docker 命令:D
You can use the command你可以使用命令
sudo service docker stop && sudo service docker start
OR要么
sudo service docker restart
to simply restart it.只需重新启动它。
The best way to find out why Docker isn't working will be to run the daemon manually.找出 Docker 不工作原因的最佳方法是手动运行守护程序。
$ sudo service docker stop
$ ps aux | grep docker # do this until you don't see /usr/bin/docker -d
$ /usr/bin/docker -d
The Docker daemon logs to STDOUT, so it will start spitting out whatever it's doing. Docker 守护进程记录到 STDOUT,所以它会开始吐出它正在做的任何事情。
Here was what my problem was:这是我的问题:
[8bf47e42.initserver()] Creating pidfile
2015/01/11 15:20:33 pid file found, ensure docker is not running or delete /var/run/docker.pid
This was because the instance had been cloned from another virtual machine.这是因为该实例是从另一个虚拟机克隆的。 I just had to remove the pidfile, and everything worked afterwards.
我只需要删除 pidfile,然后一切正常。
Of course, instead of blindly assuming this will work, I'd suggest running the daemon manually one more time and reviewing the log output for any other errors before starting the service back up.当然,与其盲目地假设这会起作用,我建议再手动运行一次守护程序并在启动服务备份之前查看日志输出是否有任何其他错误。
Do a ps aux | grep docker
做一个
ps aux | grep docker
ps aux | grep docker
to see if the daemon is running. ps aux | grep docker
查看守护进程是否正在运行。 If not run /etc/init.d/docker start
如果没有运行
/etc/init.d/docker start
If you get the message Can't connect to docker daemon. Is 'docker -d' running on this host?
如果您收到消息
Can't connect to docker daemon. Is 'docker -d' running on this host?
Can't connect to docker daemon. Is 'docker -d' running on this host?
, you can check it by docker version
. ,可以通过
docker version
查看。
If you see the information like Docker Client is running.如果您看到Docker Client is running 之类的信息。 but Docker Server is not , it's obviously you need to start the Docker server.
但 Docker Server 不是,显然你需要启动 Docker 服务器。
In CentOS, you can use service
to start or stop the Docker server.在 CentOS 中,您可以使用
service
来启动或停止 Docker 服务器。
$ sudo service docker stop
$ sudo service docker start
Then, after you type docker version
, you will get the information of Docker Client and Docker Server , and the Docker daemon has been started.然后,在输入
docker version
,您将获得Docker Client 和 Docker Server 的信息,并且 Docker 守护进程已经启动。
I have similar problem.我有类似的问题。 I had to logout and login again to shell because I have just installed Docker and following command didn't show in my environment.
我不得不注销并再次登录到 shell,因为我刚刚安装了 Docker 并且以下命令没有显示在我的环境中。
export DOCKER_HOST=127.0.0.1:4243 >> ~/.bashrc
I restart Docker after installing it:安装后我重新启动Docker:
$ sudo service docker stop
$ sudo service docker start
And it works.它有效。
Use the new Docker Community Edition app for macOS.使用适用于 macOS 的新Docker 社区版应用程序。 For example:
例如:
Uninstall all Docker Homebrew packages which you've installed so far:卸载您目前安装的所有 Docker Homebrew 软件包:
brew uninstall docker-compose brew uninstall docker-machine brew uninstall docker
Install an app manually or via Homebrew-Cask :手动或通过Homebrew-Cask安装应用程序:
brew install --cask docker
Note: This app will create necessary links to docker
, docker-compose
, docker-machine
, etc.注意:此应用程序将创建到
docker
、 docker-compose
、 docker-machine
等的必要链接。
docker
, docker-compose
, docker-machine
commands as usual in the Terminal .docker
、 docker-compose
、 docker-machine
命令。 Related:有关的:
Download the Docker CE from the download page and follow the instructions.从下载页面下载Docker CE并按照说明进行操作。
I have faced this problem, and I restarted Docker using these commands:我遇到了这个问题,我使用以下命令重新启动了 Docker:
$ sudo service docker stop
$ sudo service docker start
But I did not solve my problem, because I forgot to execute my Docker commands without sudo
.但是我没有解决我的问题,因为我忘记在没有
sudo
情况下执行我的 Docker 命令。 For those who faces this problem, try to check that.对于那些面临这个问题的人,试着检查一下。
Try尝试
$ sudo docker info
instead of this:而不是这个:
$ docker info
I have the same error and trying docker-machine regenerate-certs
or eval..
did not work for me.我有同样的错误,尝试
docker-machine regenerate-certs
或eval..
对我不起作用。
This on OS X 10.11.3 (El Capitan) and Docker v1.10.1.这适用于 OS X 10.11.3 (El Capitan) 和 Docker v1.10.1。 I was able to fix it only by deleting and recreating docker-machine again.
我只能通过再次删除并重新创建 docker-machine 来修复它。 Source
来源
If running docker-machine ls
, it shows you a similar output to the one below;如果运行
docker-machine ls
,它会显示与下面类似的输出;
DOCKER
码头工人
Unknown
未知
ERRORS
错误
Unable to query docker version: Cannot connect to the docker engine endpoint
无法查询 docker 版本:无法连接到 docker 引擎端点
Try removing your Docker machine with;尝试删除您的 Docker 机器;
docker-machine rm -f default
Where default
is your Docker machine name.其中
default
是您的 Docker 机器名称。 Then;然后;
docker-machine create -d virtualbox default
Creates a new Docker machine.创建一个新的 Docker 机器。
Double check that everything looks normal now (no errors or unknown Docker) with:使用以下命令仔细检查一切是否正常(没有错误或未知的 Docker):
docker-machine ls
Finally don't forget to run "$(docker-machine env default)"
before you continue or run the Docker Quickstart Terminal which does it for you...最后,在继续或运行 Docker 快速入门终端之前,不要忘记运行
"$(docker-machine env default)"
,它会为您执行此操作...
I knew that there are plenty of answers already in this post.我知道这篇文章中已经有很多答案了。 Just I would like to add one simple answer that is solved the above mentioned problem .
只是我想添加一个解决上述问题的简单答案。
sudo systemctl start docker
Run the above command and it will start all the docker related threads/services.运行上面的命令,它将启动所有与 docker 相关的线程/服务。
Try adding the current user to docker
group:尝试将当前用户添加到
docker
组:
sudo usermod -aG docker $USER
Then log out and login.然后注销并登录。
I had the same problem - "Can't connect to docker daemon."我遇到了同样的问题 - “无法连接到 docker 守护进程。” (except I didn't get any 'file not found' errors on trying to start the server.)
(除非我在尝试启动服务器时没有收到任何“找不到文件”错误。)
'ps' showed that "/usr/bin/docker -d" was still running 'ps' 显示 "/usr/bin/docker -d" 仍在运行
I realised that I'd never actually succeeded in running the server myself though.我意识到我自己从未真正成功地运行过服务器。 Every attempt had produced
每一次尝试都产生了
...
2014/03/24 21:57:29 pid file found, ensure docker is not running or delete /var/run/docker.pid
So I belatedly realised that installing docker had maybe registered the daemon with upstart, which had started it for me.所以我很晚才意识到安装 docker 可能已经向 upstart 注册了守护进程,它为我启动了它。 Hence, trying to kill the daemon to manually restart it fails (operation not permitted).
因此,尝试终止守护进程以手动重新启动它会失败(不允许操作)。 So I did a
所以我做了一个
sudo kill -9 <PID>
on the daemon process.在守护进程上。 Another daemon immediately took its place, and this new one DOES now let my CLI client connect:
另一个守护进程立即取而代之,这个新守护进程现在让我的 CLI 客户端连接:
$ sudo docker info
Containers: 0
Images: 0
Driver: aufs
Root Dir: /var/lib/docker/aufs
Dirs: 0
WARNING: No memory limit support
WARNING: No swap limit support
I just had the same issue, running on Amazon AWS .我刚刚遇到了同样的问题,在Amazon AWS上运行。
Here's what I attempted:这是我的尝试:
docker-machine
locally with already existing AWS instancedocker-machine
dockerd
did work...dockerd
确实有效...... It was tested following on the remote machine:在远程机器上进行了以下测试:
service docker start # Also restart, no success
systemctl start docker # Also restart, no success
dockerd # Success
I removed /var/lib/docker
and uninstalled everything, but there was no success after reinstallation.我删除了
/var/lib/docker
并卸载了所有内容,但重新安装后没有成功。 Unfortunately I have no logs stored from failures, but docker.service
just refused to start.不幸的是,我没有存储失败的日志,但是
docker.service
只是拒绝启动。
However, what finally solved my issue was basically:但是,最终解决我的问题的基本上是:
sudo usermod -aG docker $(whoami)
Following Docker's DOC site: Manage Docker as a non-root user关注 Docker 的 DOC 站点: 以非 root 用户身份管理 Docker
1) Create Docker Group 1) 创建 Docker 组
sudo groupadd docker
2) Make user belong to docker group to get the group's privileges. 2) 使用户属于 docker 组以获得该组的权限。
sudo usermod -aG docker $USER
Check whether the DOCKER_HOST environment variable is set for your shell.检查是否为您的 shell 设置了 DOCKER_HOST 环境变量。
env | grep DOCKER_HOST
If it exists,如果存在,
unset DOCKER_HOST
Then this should work:那么这应该工作:
docker run hello-world
I got the same problem.我遇到了同样的问题。 In CentOS 6.5:
在 CentOS 6.5 中:
ps aux |grep `cat /var/run/docker.pid`
If it shows no Docker daemon process exists, then I type:如果它显示不存在 Docker 守护进程,那么我输入:
docker -d
Then Ctrl + D to stop Docker.然后Ctrl + D停止 Docker。 Because we use the
-d
option, Docker will run as daemon.因为我们使用了
-d
选项,Docker 将作为守护进程运行。 Now we can do:现在我们可以这样做:
service docker start
Then I can do a docker pull centos
.然后我可以做一个
docker pull centos
。 That's all.就这样。
NOTE: If these do not work, you can try yum update
, and then repeat these again, because I yum install
before these.注意:如果这些都不起作用,您可以尝试
yum update
,然后再次重复这些,因为我yum install
在这些之前。
If you are running on OS X using Docker tool, follow this.如果您使用 Docker 工具在 OS X 上运行,请按照此操作。
Restart the daemon and configure your environment:重新启动守护进程并配置您的环境:
docker-machine restart
And then接着
docker-machine env
Finally,最后,
eval $(docker-machine env)
To test the daemon is running:要测试守护程序是否正在运行:
docker ps -a
or docker-machine ls
. docker ps -a
或docker-machine ls
。 This will list all containers.这将列出所有容器。
The Docker Service may not be running. Docker 服务可能未运行。
If you are on a RedHat/Fedora/CentOS, please try this:如果您使用的是 RedHat/Fedora/CentOS,请尝试以下操作:
sudo systemctl start docker
If you are on Ubuntu/Debian:如果您使用的是 Ubuntu/Debian:
sudo service start docker
Docker will start running on your host and respective port. Docker 将开始在您的主机和相应端口上运行。
为了解决这个问题,我必须启用 docker 服务:
sudo systemctl enable /usr/lib/systemd/system/docker.service
To fix, you need to issue the following commands in the terminal.要修复,您需要在终端中发出以下命令。 I'll explain each step:
我将解释每个步骤:
# Uninstall Docker from apt packages
$ sudo apt-get remove docker docker.io
# Remove it from the libraries just to be
# sure it's gone forever
$ sudo rm -rf /var/lib/docker/*
Now, if you want to simplify things and get more time, you can run my init
script with the parameter installDocker
:现在,如果您想简化事情并获得更多时间,可以使用参数
installDocker
运行我的init
脚本:
# Pull the init script from GitHub
$ wget https://github.com/dminca/dotfiles/blob/master/init
# Add rights to run the script
$ chmod 755 init
# Just run the script with the installDocker parameter
$ ./init installDocker
A reboot is optional, but I suggest you do it to be sure all runs smoothly.重新启动是可选的,但我建议您这样做以确保一切顺利运行。
Check if you are using Docker Machine :)检查您是否正在使用 Docker 机器 :)
Run docker-machine env default
should do the trick.运行
docker-machine env default
应该可以解决问题。
Because according to documentation:因为根据文档:
Docker Machine is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with
docker-machine
commands.Docker Machine 是一个工具,可以让你在虚拟主机上安装 Docker Engine,并使用
docker-machine
命令管理主机。 You can use Machine to create Docker hosts on your local Mac or Windows box, on your company network, in your data center, or on cloud providers like AWS or Digital Ocean.您可以使用 Machine 在本地 Mac 或 Windows 机器、公司网络、数据中心或 AWS 或 Digital Ocean 等云提供商上创建 Docker 主机。
Using
docker-machine
commands, you can start, inspect, stop, and restart a managed host, upgrade the Docker client and daemon, and configure a Docker client to talk to your host.使用
docker-machine
命令,您可以启动、检查、停止和重新启动托管主机,升级 Docker 客户端和守护程序,以及配置 Docker 客户端与您的主机通信。Point the Machine CLI at a running, managed host, and you can run
docker
commands directly on that host.将 Machine CLI 指向正在运行的托管主机,您可以直接在该主机上运行
docker
命令。 For example, rundocker-machine env default
to point to a host calleddefault
, follow on-screen instructions to completeenv
setup, and rundocker ps
,docker run hello-world
, and so forth.例如,运行
docker-machine env default
以指向名为default
的主机,按照屏幕上的说明完成env
设置,然后运行docker ps
、docker run hello-world
等。
https://docs.docker.com/machine/overview/ https://docs.docker.com/machine/overview/
I had the same problem running Docker 1.10 on Ubuntu 14.04 and none of the given answers worked.我在 Ubuntu 14.04 上运行 Docker 1.10 时遇到了同样的问题,但给出的答案都没有奏效。 For me, the fix was to specify the storage driver when running the Docker daemon.
对我来说,修复是在运行 Docker 守护进程时指定存储驱动程序。
sudo docker daemon --storage-driver=devicemapper
I had a similar issue.我有一个类似的问题。
In my case the solution was to remove a deprecated version of docker.就我而言,解决方案是删除不推荐使用的 docker 版本。 This I assume was causing some conflicts.
我认为这引起了一些冲突。
On ubuntu:在 Ubuntu 上:
sudo apt remove docker
solved the problem for me为我解决了问题
you can run the daemon with the following command:您可以使用以下命令运行守护程序:
sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
The script leaves the daemon running in the background, and with the Docker ready you can test that it is accepting commands.该脚本使守护程序在后台运行,并且在 Docker 准备就绪后,您可以测试它是否正在接受命令。
sudo docker info
for more information check this out: https://www.upcloud.com/support/how-to-configure-docker-swarm/有关更多信息,请查看: https://www.upcloud.com/support/how-to-configure-docker-swarm/
After I update my Docker version to 0.8.0
, I get an error message while entering sudo docker version
:将Docker版本更新为
0.8.0
,输入sudo docker version
时收到错误消息:
Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
2014/02/19 12:54:16 Can't connect to docker daemon. Is 'docker -d' running on this host?
And I've followed the instructions and entered command sudo docker -d
, and I got this:我已经按照说明进行操作,并输入了命令
sudo docker -d
,我得到了:
[/var/lib/docker|2462000b] +job initserver()
[/var/lib/docker|2462000b.initserver()] Creating server
open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory[/var/lib/docker|2462000b] -job initserver() = ERR (1)
2014/02/19 12:55:57 initserver: open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory
How do I solve the problem?我该如何解决这个问题?
A lot of answers already but in the hope that this helps someone.已经有很多答案,但希望这对某人有所帮助。 This is an issue that occurs when you install docker via snap.
这是通过 snap 安装 docker 时出现的问题。 Running via sudo would allow you to connect to the daemon, but this leads to other issues.
通过 sudo 运行将允许您连接到守护程序,但这会导致其他问题。 The solution is to perform some steps BEFORE you install the snap package making the complete list of steps:
解决方案是在安装 snap package 之前执行一些步骤,制作完整的步骤列表:
sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
sudo snap install docker
After doing this, docker will connect to the daemon and work without sudo, no restart required.完成此操作后,docker 将连接到守护程序并无需 sudo 即可工作,无需重新启动。
https://github.com/docker-archive/docker-snap/issues/1#issuecomment-423778054 https://github.com/docker-archive/docker-snap/issues/1#issuecomment-423778054
Try to change the Docker configuration file, docker
or docker-network
in /etc/sysconfig
:尝试在
/etc/sysconfig
中更改 Docker 配置文件docker
或 docker docker-network
:
(... ~ v1.17) (... ~ v1.17)
docker
file: docker
文件:OPTIONS= -H fd://
or (v1.18):或(v1.18):
docker-network
file: docker-network
文件:DOCKER_NETWORK_OPTIONS= -H unix:///var/run/docker.sock
Have you tried turning it off and on again?你试过把它关掉再打开吗? :-)
:-)
I had the same issue after upgrading to Docker 1.10.1 on my Mac.在我的 Mac 上升级到 Docker 1.10.1 后,我遇到了同样的问题。 I did the following:
我做了以下事情:
On the Docker Quickstart Terminal在 Docker 快速入门终端上
$ exit
$退出
$ exit
$退出
then然后
docker-machine kill default
docker-machine 杀死默认值
then restarted Docker Quickstart Terminal然后重新启动 Docker 快速启动终端
This solved my problem.这解决了我的问题。
If regenerating TLS certificates doesn't work 如果重新生成TLS证书不起作用
docker-machine regenerate-certs default
Try restarting the docker machine and setting the env variable: 尝试重新启动docker机器并设置env变量:
docker-machine restart default
eval $(docker-machine env default)
Check if the machine is running with: 检查机器是否正在运行:
docker-machine ls
or alternatively 或者
docker run hello-world
This worked for me. 这对我有用。 However, if you still don't have the daemon up, Docker's troubleshooting page details a process for stopping, removing and creating a new machine.
但是,如果您仍然没有守护程序, Docker的故障排除页面会详细说明停止,删除和创建新计算机的过程。
I also got the issue "Cannot connect to the Docker daemon. Is the docker daemon running on this host?". 我还遇到了“无法连接到Docker守护程序的问题。这个主机上是否运行了docker守护程序?”。
I had forgot to use sudo
. 我忘了使用
sudo
。 Hope it will help some of us. 希望它能帮助我们中的一些人。
$:docker images
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
$:sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Ok so I started having this problem today. 好的,我今天开始遇到这个问题。 Then I saw a lot of responses but none seem to have worked for me.
然后我看到了很多回复,但似乎没有一个对我有用。 First most of the instructions where directed to linux.
首先是大多数指向linux的指令。 And for the mac version they were all talking about running 'docker-machine'.
而对于Mac版本,他们都在谈论运行'docker-machine'。 I assume you use docker-machine if you install docker toolbox because then docker will be running in a virtual machine for windows and mac platforms.
我假设您使用docker-machine如果您安装docker工具箱,因为docker将在Windows和Mac平台的虚拟机中运行。 But its 2017 now and docker for mac is really stable hence no need for using the toolbox.
但它的2017年现在和mac的docker非常稳定,因此不需要使用工具箱。
Not sure how the daemon stopped though. 不知道守护进程是如何停止的。 But to restart it all I had to do was go "Applications" and double click on the docker icon.
但要重新启动它,我所要做的就是去“应用程序”并双击docker图标。 I was asked to update and Relaunched which I accepted.
有人要求我更新并重新启动我接受的内容。 After that everything worked like a charm.
之后,一切都像魅力一样。
On the Mac OS-X, this could just mean the docker installation is out-dated or not running.在 Mac OS-X 上,这可能只是意味着 docker 安装已过时或未运行。 Simply download the latest docker from the offical site and install it.
只需从官方网站下载最新的 docker 并安装即可。
Worked for me.为我工作。
With Docker installed with snap
, I sometimes encounter the OP's error upon rebooting my machine.随着 Docker 安装
snap
,我有时会在重新启动机器时遇到 OP 错误。 In my case, running sudo snap logs docker
revealed an error in the logs:就我而言,运行
sudo snap logs docker
在日志中显示错误:
Error starting daemon: pid file found, ensure docker is not running or delete /var/snap/docker/423/run/docker.pid
启动守护程序时出错:找到 pid 文件,确保 docker 未运行或删除 /var/snap/docker/423/run/docker.pid
After running sudo rm /var/snap/docker/423/run/docker.pid
, I can start Docker normally.运行
sudo rm /var/snap/docker/423/run/docker.pid
后,我可以正常启动 Docker。
Usually this never happens.通常这永远不会发生。 But one day the message appeared (as bellow) and a simple reboot fixed it
但是有一天消息出现了(如下所示)并且简单的重启修复了它
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Run the following command:运行以下命令:
docker context use default
My problem was, that default path of docker.sock was not where docker daemon was.我的问题是,docker.sock 的默认路径不在 docker 守护程序所在的位置。
My default was /home/user/.docker, but docker daemon was in /var/bin.我的默认值是 /home/user/.docker,但 docker 守护进程在 /var/bin 中。
i did set env variable to set correct address and that fixed the issue我确实设置了环境变量以设置正确的地址并解决了问题
export DOCKER_CONFIG = '/var/bin'
https://docs.docker.com/engine/reference/commandline/cli/ https://docs.docker.com/engine/reference/commandline/cli/
I installed docker desktop on ubuntu so that might be the issue or why my DOCKER_CONFIG was not set right.我在 ubuntu 上安装了 docker 桌面,所以这可能是问题所在,或者为什么我的 DOCKER_CONFIG 设置不正确。
I'm surprised no one answered this already:我很惊讶没有人回答这个问题:
sudo docker network create persistence_backend
Do this if your both running docker and docker-compose如果您同时运行 docker 和 docker-compose,请执行此操作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.