2

I am building craft cms in docker and I am getting the following error, when I execute docker-compose up:

ERROR: for craftcms Cannot start service craftcms: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\"/host_mnt/c/src/composer.lock\\" to rootfs \\"/var/lib/docker/overlay2/b7084475699f911f17d38746b21b1b9694fedf6e096a4080109d429fa687a6db/merged\\" at \\"/var/lib/docker/overlay2/b7084475699f911f17d38746b21b1b9694fedf6e096a4080109d429fa687a6db/merged/var/www/composer.lock\\" 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 ERROR: Encountered errors while bringing up the project.

Apparently, mounting directories in Windows OS is different than Linux OS. Could you please help me troubleshoot this?

enter image description here

UPDATE

From the docker-compose.yml, this is where I mount the files:

craftcms:
    build:
      context: .
      dockerfile: ./infrastructure/docker/php-fpm/Dockerfile
    expose:
      - 9000
    volumes:
      - cpresources:/var/www/web/cpresources
      - ./src/vendor:/var/www/vendor
      - ./src/composer.json:/var/www/composer.json
      - ./src/composer.lock:/var/www/composer.lock
      - ./src/config:/var/www/config
      - ./src/modules:/var/www/modules
      - ./src/templates:/var/www/templates
      - ./src/web:/var/www/web
dimitrisd
  • 566
  • 1
  • 9
  • 30
  • 1
    Provide your docker-compose files. It seems you re trying to mount file. – mchawre Jun 25 '19 at 09:53
  • 4
    Please do not post photos of text, post the text with code formatting instead. Otherwise, people that wish to answer your question with a copy of the code snippit need to manually retype the text from your picture, and anyone searching for similar issues will not find your question. – BMitch Jun 25 '19 at 10:37

1 Answers1

3

This typically indicates that src/composer.lock is either not a file, or that the drive where these files exist is not properly shared to the docker VM.

For the former, check the directory where you are running docker-compose from, this is the censored directory so I cannot provide you better details than that. You should have a src\composer.lock in there as a regular file, not a directory.

For the latter, go into the docker preferences, and reconfigure the drive sharing to ensure the drive with your compose project is included, and that docker has your current password (it performs a windows SMB mount to share the drive to the docker VM).

When docker tries to mount a file that does not exist as a host mount, the default action is to create a directory on the host (this may be only in the docker VM if the directory is not properly shared) and mount that directory inside the container. And if that is supposed to be a file instead of a directory inside the container, you will get an error.

BMitch
  • 231,797
  • 42
  • 475
  • 450