我正在使用远程上下文通过docker-compose部署很少的Docker服务。我将其配置为使用SSH:
docker context create remote --docker "host=ssh://user@my.remote.host"
docker context use remote在远程主机上,我有多个配置文件,我想要挂载到Docker。当我尝试使用docker CLI时,它运行得很好:
docker run -v /home/user/run:/test -it alpine:3.11
# ls -la /test
-> shows remote files correctly here但是,当我使用配置文件使用docker-compose启动它时:
version: "3.3"
services:
nginx:
image: nginx:1.17.10-alpine
container_name: nginx
restart: unless-stopped
volumes:
- ${HOME}/run/nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
- "443:443"由于某种原因,它试图挂载本地文件而不是远程文件,但失败时出错:
ERROR: for nginx Cannot start service nginx: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"rootfs_linux.go:58: mounting \\\"/home/local-user/run/nginx.conf\\\" to rootfs \\\"/hdd/docker/overlay2/c869ef9f2c983d33245fe1b4360eb602d718786ba7d0245d36c40385f7afde65/merged\\\" at \\\"/hdd/docker/overlay2/c869ef9f2c983d33245fe1b4360eb602d718786ba7d0245d36c40385f7afde65/merged/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type是否可以通过类似于标准Docker的docker-compose安装远程资源?
发布于 2020-10-14 10:21:49
您需要显式地设置DOCKER_HOST来访问您的远程对接主机。
从撰写文档中
DOCKER_HOST 设置停靠守护进程的URL。与Docker客户机一样,默认为unix:/var/run/docker.sock。
在给定的情况下,docker context use remote只为您的docker命令将当前上下文设置为remote。仍然使用默认(本地)上下文。为了让docker检测它,您必须通过DOCKER_HOST环境变量传递它。
示例:
$ export DOCKER_HOST=ssh://user@my.remote.host
$ docker-compose uphttps://stackoverflow.com/questions/62811751
复制相似问题