如何在不使用套接字文件的情况下将堆栈指向 docker 守护进程?

How can I point stack at docker daemon started without using the socket file?

如果我们使用 -H 1.2.3.4:7777 等标志启动 docker 守护程序,则不会创建 /var/run/docker.sock 文件和各种 stack 操作,例如 stack docker pull失败:

$ stack docker pull Pulling image from registry: 'tweag/haskellr:latest' Post http:///var/run/docker.sock/v1.20/images/create?fromImage=tweag%2Fhaskellr%3Alatest: dial unix /var/run/docker.sock: no such file or directory. * Are you trying to connect to a TLS-enabled daemon without TLS? * Is your docker daemon up and running? Could not pull Docker image: tweag/haskellr:latest There may not be an image on the registry for your resolver's LTS version in stack.yaml

我们如何告诉 stack 使用特定主机上的守护进程?

这最初是在 GitHub 上提出的。答案是设置 DOCKER_HOST 环境变量,例如 DOCKER_HOST="1.2.3.4:7777".