Docker-Compose停止在Debian 11上安装Docker Desktop工作

发布于 2025-02-02 02:40:11 字数 412 浏览 4 评论 0原文

我在Debian 11 Machine上安装了Linux的Docker桌面。

安装后,我无法使用Docker-Compose或Laravel帆。 错误是:

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_host env变量。

Docker CLI仍在正常工作。

有人可以帮我吗? 提前致谢

I installed Docker Desktop for Linux on my Debian 11 machine.

After the installation, I'm not able to use docker-compose or laravel sail.
The error is:

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.

The DOCKER_HOST env variable is not set.

The docker CLI is still working properly.

Someone can help me?
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甲如呢乙后呢 2025-02-09 02:40:11

编辑:

最快,最清洁的方式:

检查“启用Docker在Docker桌面设置的常规部分中构成V1/V2兼容模式”

tldr:

  1. 运行命令docker上下文ls发现新主机。

  2. 复制 docker端点对应于 desktop-linux 上下文

  3. docker endpoint ,通过选择这两种方法之一: P>


<强>长答案和解释:

linux上的 docker桌面 在虚拟机上运行,并使用 docker compose v2 而不是docker-compose (使用它的命令是docker组成的没有连字符)。

为了避免它在本地计算机上掩盖Docker Engrion服务,并创建一个新的上下文

由于已经掩盖了本地 docker 服务,因此它不再在您的本地计算机上运行。

上下文可以切换到默认一个,如果您想使用docker引擎而不是Docker桌面。这样,您当地的码头组合将像以前一样工作。

另一种方法是将本地docker-compose 连接到新虚拟机上的 docker桌面主机。

这可以通过两种方式完成:

  1. 通过使用环境变量,如上所述,在 tldr 部分中所述。
  2. 通过将主机地址传递到 docker-compose 命令:docker-compose -h {docker endpoint}命令

EDIT:

Fastest and cleaner way:

Check "Enable Docker Compose V1/V2 compatibility mode" in the General section of the Docker Desktop settings.

TLDR:

  1. Run the command docker context ls to discover the new host.

  2. Copy the DOCKER ENDPOINT corresponding to the desktop-Linux context

  3. Set the DOCKER_HOST environment variable by choosing one of those two methods:

    • Open a terminal and execute export DOCKER_HOST={your docker endpoint} (this is valid only for the current terminal session and you will lose the config on system reboot)
    • Follow those instructions to set a permanent environment variable (you have to use DOCKER_HOST as a variable name and your own DOCKER ENDPOINT as a value, not the ones used as an example in the answer)

Long answer and explanation:

The Docker Desktop on Linux runs on a virtual machine and uses docker compose V2 instead of docker-compose (the command to use it is docker compose without the hyphen).

To avoid it masks the docker engine service on the local machine and creates a new context.

As the local Docker service has been masked, it is not running anymore on your local machine.

The context can be switched to the default one if you want to use Docker Engine instead of Docker Desktop. That way your local docker-compose will work as before.

Another way is to connect the local docker-compose to the Docker Desktop host on the new virtual machine.

This can be done in two ways:

  1. By using an environment variable, as explained above in the TLDR section.
  2. By passing the host address to the docker-compose command: docker-compose -H {your docker endpoint} COMMAND
浅紫色的梦幻 2025-02-09 02:40:11
  1. Docker上下文LS
    给输出
DOCKER ENDPOINT: unix:///var/run/docker.sock 
chmod 666 /var/run/docker.sock
  1. 然后给出
docker-compose up -d

它将起作用

  1. docker context ls
    give output
DOCKER ENDPOINT: unix:///var/run/docker.sock 
chmod 666 /var/run/docker.sock
  1. then give
docker-compose up -d

it will work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文