gpt4 book ai didi

docker - 无法运行docker-compose

转载 作者:行者123 更新时间:2023-12-02 19:28:27 26 4
gpt4 key购买 nike

在Jhipster上this article之后,我构建了该项目。但是,我无法运行docker-compose。因此,我尝试找出问题所在。我不走运地一步步走这篇Docker-Compose文章。

$ sudo service docker status
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-12-27 15:40:22 PST; 2 days ago
Docs: https://docs.docker.com
Main PID: 1960 (dockerd)
Tasks: 20 (limit: 4440)
Memory: 68.2M
CGroup: /system.slice/docker.service
├─1960 /usr/bin/dockerd -H fd://
└─2093 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --s

Dec 27 15:40:10 tk-PC dockerd[1960]: time="2018-12-27T15:40:10.493340278-08:00" level=warning msg="Your kernel does not support swap memory li
Dec 27 15:40:10 tk-PC dockerd[1960]: time="2018-12-27T15:40:10.493612101-08:00" level=warning msg="Your kernel does not support cgroup rt peri
Dec 27 15:40:10 tk-PC dockerd[1960]: time="2018-12-27T15:40:10.493681034-08:00" level=warning msg="Your kernel does not support cgroup rt runt
Dec 27 15:40:10 tk-PC dockerd[1960]: time="2018-12-27T15:40:10.496381656-08:00" level=info msg="Loading containers: start."
Dec 27 15:40:17 tk-PC dockerd[1960]: time="2018-12-27T15:40:17.498415923-08:00" level=info msg="Default bridge (docker0) is assigned with an I
Dec 27 15:40:19 tk-PC dockerd[1960]: time="2018-12-27T15:40:19.646853084-08:00" level=info msg="Loading containers: done."
Dec 27 15:40:22 tk-PC dockerd[1960]: time="2018-12-27T15:40:22.512083092-08:00" level=info msg="Daemon has completed initialization"
Dec 27 15:40:22 tk-PC dockerd[1960]: time="2018-12-27T15:40:22.512266914-08:00" level=info msg="Docker daemon" commit=89658be graphdriver=aufs
Dec 27 15:40:22 tk-PC dockerd[1960]: time="2018-12-27T15:40:22.553322342-08:00" level=info msg="API listen on /var/run/docker.sock"
Dec 27 15:40:22 tk-PC systemd[1]: Started Docker Application Container Engine.

$ sudo ls -la /var/run/docker.sock
srw-rw---- 1 root docker 0 Dec 27 15:39 /var/run/docker.sock

$ sudo usermod -aG docker ${USER}

$ docker-compose -f docker-compose.yml build --build-arg UID=$(id -u)
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.

最后一步的结果与“docker-compose up -d”相同。根据这篇文章,如果此刻问题仍然存在,那将是一个权限问题。我如何找到许可问题?

最佳答案

有多种方法可以解决此问题。首先尝试使用以下命令导出docker host的环境变量:

export DOCKER_HOST=/var/run/docker.sock

如果可行,您可以将同一行添加到bashrc配置中以永久保存此导出。

如果它不起作用,您可以尝试修改docker daemon配置。它位于
/etc/docker/daemon.json

您需要像这样将localhost附加到主机上:
"hosts": ["old_hosts_not_modified_only_append_new_one", "tcp://localhost:2376"],

然后使用以下命令重新启动docker daemon:
service docker restart

希望对你有帮助

关于docker - 无法运行docker-compose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53974334/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com