欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-03-12 12:33:36
...

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

[[email protected] ~]$ 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://*.com/questions/44678725/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docker