简体   繁体   中英

Docker Compose file will not mount

I'm trying to mount a file into my container in my docker-compose.yaml file like so:

version: "3"
services:
  data-service:
    volumes:
      - /path/to/file.js:/usr/src/app/file.js

But I made a mistake. The first time I did a docker-compose up , the file did not exist on my host machine. Whatever happened during that run made some permanent change somewhere because I placed the file in the correct location, but when I do a docker-compose up , I still get the following error:

ERROR: for data-service  Cannot start service data-service: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/path/to/file.js\\\" to rootfs \\\/var/lib/docker/overlay2/{really long hash}/merged\\\" at \\\"/var/lib/docker/overlay2/{same hash}/merged/usr/src/app/file.js\\\ 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

Here's the interesting bit: The docker-compose file works fine for my whole team except for me and one other team member who made the mistake of running it before the file existed the first time.

Since adding the file doesn't fix the problem, it appears that the problem is somehow getting "cached" (for lack of a better term). I thought maybe pruning my volumes would help (in case a spurious volume w/ the name of the file path had been created). But it did not help.

Anyone have any ideas what could cause the problem to persist for us?

volumes should be a directory.

try:

version: "3"
services:
  data-service:
    volumes:
      - /path/to:/usr/src/app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM