ERROR: Couldn’t connect to Docker daemon at http+docker://localhost – is it running?
程序员文章站
2022-03-12 12:27:01
...
问题:
centos7安装docker-compose,尝试启动时报错:
docker-compose up -d
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
解决方案:
一般会,报这个错误会有2种可能的原因:
原因1:
最常见的原因,因为当前所使用的用户没有访问docker的权限.
如果是这个原因,那么你可以尝试
- 使用
sudo
来以root身份运行它,但是这么做需要你将docker-compose
放到usr/bin/
目录下.
sudo cp `which docker-compose` /usr/bin/
sudo docker-compose up -d
- 或者,可以将用户添加到docker组
sudo usermod -a -G docker $USER
添加完成后,需要先登出,再次登录才可以,或者你也可以直接重启系统…
或者是切换到root用户,在从root用户再次切换到当前用户,这样相当于重新登录.
假设你用的用户是leo
# 切换至root
su -
# 再从root切换到leo
su - leo
# 启动docker-compose
docker-compose up -d
原因2:
没有启动docker服务
这种原因很好解决,查看docker服务是否启动,没启动的话启动就ok了
# 查看docker服务是否启动
sudo systemctl status docker
# 如果没有启动
sudo systemctl start docker
推荐阅读
-
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
-
Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
-
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
-
ERROR: Couldn‘t connect to Docker daemon at http+docker://localhost - is it running?
-
解决ERROR: Couldn't connect to Docker daemon at http://127.0.0.1:4243 - is it running
-
解决 docker中 error:Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
-
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
-
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
-
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?
-
解决ERROR: Couldn't connect to Docker daemon at http://127.0.0.1:4243 - is it running