Docker volume binds file as directory on remote linux server

I have docker installed on linux on remote server. I use ssh to connect to docker from my host machine with Windows 10. To deploy my app to docker, I use docker-compose v3, but I have serious problem. When I try to mount volume with file from my host machine, file converts to directory in my container.
Here's my 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

And this is my error after command 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

Upvotes: 2

Views: 1179

Answers (1)

acran
acran

Reputation: 9018

I understand that you are trying to mount a local folder from your Windows host (C:/Users/Aset/IdeaProjects/...) into a docker container.

But this is not possible (that easily) since docker can only mount folders local to the docker host i.e. your remote server you're connecting to via ssh.

So in order to mount the folder of your local Windows host into the container you'd first have to mount that folder somehow on the docker host/remote server (e.g. with a Samba share) or copy the contents of that folder to the remote server and edit your volume source to the path of the folder on the docker host.

P.S. in case you're wondering why this doesn't work but docker build with files from your Windows host does: docker build uploads the build context i.e. the current directory, to the docker host making its content available on the server.

Upvotes: 2

Related Questions