【问题标题】:Docker volume binds file as directory on remote linux serverDocker 卷将文件绑定为远程 linux 服务器上的目录
【发布时间】:2020-08-23 11:51:56
【问题描述】:

我在远程服务器的 linux 上安装了 docker。我使用 ssh 从装有 Windows 10 的主机连接到 docker。要将我的应用程序部署到 docker,我使用 docker-compose v3,但我遇到了严重的问题。当我尝试使用主机中的文件挂载卷时,文件将转换为容器中的目录。
这是我的 docker-compose.yml:

version: "3.8"
services:
zeebe:
    container_name: zeebe
    image: camunda/zeebe
    environment:
      - ZEEBE_LOG_LEVEL=debug
    ports:
      - "26500:26500"
      - "9600:9600"
      - "5701:5701"
    volumes:
      - zeebe_data:/usr/local/zeebe/data
      - type: bind
        source: ./ZeebeServer/lib/application.yml
        target: /usr/local/zeebe/config/application.yaml
        read_only: true
    depends_on:
      - elasticsearch
    networks:
      - backend
  operate:
    container_name: operate
    image: camunda/operate
    ports:
      - "8080:8080"
    depends_on:
      - zeebe
      - elasticsearch
    volumes:
      - operate_data:/usr/local/operate
      - type: bind
        source: C:/Users/Aset/IdeaProjects/ABC-Store/ZeebeServer/operate/application.yml
        target: /usr/local/operate/config/application.yml
        read_only: true
    networks:
      - backend
  elasticsearch:
    container_name: elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.7.1
    ports:
      - "9200:9200"
    environment:
      - discovery.type=single-node
      - cluster.name=elasticsearch
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - zeebe_elasticsearch_data:/usr/share/elasticsearch/data
    networks:
      - backend

这是我在命令 docker-compose -d up 后的错误:

ERROR: for zeebe  Cannot start service zeebe: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/c/Users/User/IdeaProjects/ABC-Store/ZeebeServer/lib/application.yml\\\" to rootfs \\\"/var/lib/docker/overlay2/fec3c1f3ad8748e2bf3aa5fdf30558434c2474ecac8b7fdbad2fdbb27df24415/merged\\\" at \\\"/var/lib/docker/overlay2/fec3c1f3ad8748e2bf3aa5fdf30558434c2474ecac8b7fdbad2fdbb27df24415/merged/usr/local/zeebe/config/application.yaml\\\" 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

【问题讨论】:

    标签: linux docker docker-compose


    【解决方案1】:

    我了解到您正在尝试将本地文件夹从 Windows 主机 (C:/Users/Aset/IdeaProjects/...) 挂载到 docker 容器中。

    但这不可能(那么容易),因为docker 只能将文件夹挂载到 docker 主机 本地,即您通过 ssh 连接到的远程服务器。

    因此,为了将本地 Windows 主机的文件夹挂载到容器中,您首先必须以某种方式将该文件夹挂载到 docker 主机/远程服务器上(例如,使用 Samba 共享)或将该文件夹的内容复制到远程服务器并将您的卷源编辑到 docker 主机上的文件夹路径。

    附:如果您想知道为什么这不起作用,但 docker build 与您的 Windows 主机中的文件确实docker build 上传 构建上下文,即当前目录,到 docker 主机,使其内容在服务器上可用。

    【讨论】:

      猜你喜欢
      • 2010-09-09
      • 1970-01-01
      • 1970-01-01
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多