解决ERROR: Couldn't connect to Docker daemon at http://127.0.0.1:4243 - is it running

使用docker-compose up -d,会提示下面的错误提示:

[xxx@docker ~]$ docker-compose up -d
ERROR: Couldn't connect to Docker daemon at http://127.0.0.1:4243 - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

解决方案如下:

1.关闭docker服务

$ sudo service docker stop

2.通过守护进程运行

sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &

3.检查端口2375是否已经有进程监听,然后配置环境变量DOCKER_HOST

netstat -anpt | grep 2375
[xxx@docker ~]$ netstat -anpt | grep 2375
(No info could be read for "-p": geteuid()=18922 but you should be root.)
tcp6       0      0 :::2375                 :::*                    LISTEN      -

$vim ~/.bashrc
export DOCKER_HOST=tcp://localhost:2375

4.运行docker-compose up -d

参考:
https://stackoverflow.com/questions/44678725/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker

猜你喜欢

转载自blog.csdn.net/yrx0619/article/details/80178018
今日推荐