When initially building containers using Docker-compose, I forgot to put a credentials.json
file in the directory before running docker-compose up
. Now Docker seems to always assume credentials.json
is a directory and not a file even if I have the file in the directory (see error below).
ERROR: for pair-backend Cannot start service pair-backend:
OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60:
mounting "/host_mnt/Users/leed36/Desktop/GitHub/pair-app/credentials.json" to rootfs at "/var/lib/docker/overlay2/6808dee4b6f47e47f39143231ee71bb1728292fb69e2a672388bc1ba42c42ebd/merged/app/credentials.json"
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
I have tried deleting the containers, docker system prune -a
and docker volume prune
and I still can't get Docker to mount this file.
Here is the docker-compose definition
container_name: pair-backend
build:
context: ./backend
dockerfile: Dockerfile
env_file:
- ./backend/.env
volumes:
- ./backend:/app/
- ./credentials.json:/app/credentials.json
The only way I can get this to work is to rename the file to some other name and change the docker-compose.yaml
- ./credentials1.json:/app/credentials.json