我的Docker服务已启动并正在运行。但是,当尝试使用Docker并使用sudo
运行它时,例如:
12:40:26/~ $ sudo docker pull fluxcapacitor/pipeline
Using default tag: latest
我收到以下错误:
Warning: failed to get default registry endpoint from daemon (Cannot connect to
the Docker daemon. Is the docker daemon running on this host?). Using system
default: https://index.docker.io/v1/
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
请注意,我已经按照Mac OS X sudo docker Cannot connect to the Docker daemon. Is the docker daemon running on this host?
上的答案进行了操作如下:
docker-machine start default
12:40:36/~ $ docker-machine start default
Starting "default"...
Machine "default" is already running.
docker ps
12:41:20/~ $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
那还需要做些什么呢?
这是:
$ docker --version
Docker version 1.11.2, build b9f10c9
on El Capitan
。
docker-machine env default
$ eval "$(docker-machine env default)"
$ docker-machine env default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/macuser/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
答案 0 :(得分:13)
以下命令导出后续docker命令使用的一些环境变量:
eval "$(docker-machine env default)"
但是,如果使用sudo启动docker,则docker可执行文件无法访问导出的环境变量。您可以通过将-E
标记传递给sudo
来使其工作,例如:
sudo -E docker pull fluxcapacitor/pipeline
但更容易的选择是使用没有root的docker:
docker pull fluxcapacitor/pipeline
答案 1 :(得分:2)
答案 2 :(得分:1)
尝试
时,我的MAC上有相同的探测器# eval "$(docker-machine env default)"
收到此错误
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": x509: certificate is valid for 192.168.99.101, not 192.168.99.100
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
重新生成证书,找出可用的docker-machines;
# docker-machine ls
可出售的码头机器的输出(省略其他)
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 Unknown Unable to query docker version: Get https://192.168.99.100:2376/v1.15/version: x509: certificate is valid for 192.168.99.101, not 192.168.99.100
为此默认docker-machine
生成证书# docker-machine regenerate-certs default
然后将docker-machine env设置为default
docker-machine;
# eval "$(docker-machine env default)"
之后它会正常工作。
答案 3 :(得分:1)
我也尝试过同样的方法,但是没有用。
后来我在AWS CLI上尝试了这些步骤
$ sudo nano /etc/docker/daemon.json
{
"dns": ["8.8.8.8", "8.8.4.4"]
}
$ sudo service docker restart
$ docker pull hello-world