Can't seem to mount file

I’m trying to learn Docker to build a PHP/NGINX setup, following this tutorial. Unfortunately, when I try to mount the nginx.conf as directed, I get this error:

ERROR: for docker_nginx_1  Cannot start service nginx: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/c/www/php_docker/docker/nginx/nginx.conf\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/overlay2/8aa58bb7a5bb80ad62c173973ea3ab627bb5d6be53ecf70bed95221d28852c4c/merged\\\" at \\\"/mnt/sda1/var/lib/docker/overlay2/8aa58bb7a5bb80ad62c173973ea3ab627bb5d6be53ecf70bed95221d28852c4c/merged/etc/nginx/nginx.conf\\\" 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: for nginx  Cannot start service nginx: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/c/www/php_docker/docker/nginx/nginx.conf\\\" to rootfs \\\"/mnt/sda1/var/lib/docker/overlay2/8aa58bb7a5bb80ad62c173973ea3ab627bb5d6be53ecf70bed95221d28852c4c/merged\\\" at \\\"/mnt/sda1/var/lib/docker/overlay2/8aa58bb7a5bb80ad62c173973ea3ab627bb5d6be53ecf70bed95221d28852c4c/merged/etc/nginx/nginx.conf\\\" 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.

I’m having trouble figuring out what’s wrong. Here’s my compose file:

version: '3'

services:
  php-fpm:
    build:
      context: ./php
    volumes:
      - ../src:/var/www

  nginx:
    build:
      context: ./nginx
    volumes:
      - ../src:/var/www
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/sites/:/etc/nginx/sites-available
      - ./nginx/conf.d/:/etc/nginx/conf.d
    depends_on:
      - php-fpm
    ports:
      - 80:80
      - 443:443

I’d love to get some help :confused:

Hi community,

I am experiencing the same issue

docker start -i matlab_container_jenkins-BuildSingleAlgo_csc-204

Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"mkdir /home/user8: 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

My Dockerfile is as follows
FROM centos

ENV DOCKER_WORKSPACE=/home/developer/workspace  

RUN groupadd -g 117 docker

RUN yum -y update && \
    yum install -y libX11

ENV PATH="/cad/app/:${PATH}"

RUN mkdir -p /home/user8

RUN groupadd -r developer -g 1001 &&\
	useradd -r -g developer -d /home/user8 user8

ENV USER_HOME=/home/user8
ENV WORK_DIR=/home/user8/workdir

RUN mkdir $WORK_DIR
WORKDIR $WORK_DIR

RUN chown -R user8:developer $USER_HOME

ADD entrypoint.sh $WORK_DIR/entrypoint.sh
RUN chmod +x $WORK_DIR/entrypoint.sh

USER user8

CMD ["./entrypoint.sh"]

So /home/user8 should defenitly be a directory, but the error message tells me it is not. How?
. Also strange is that the same configuration worked 5 dayes ago.
I also cannot use docker cp to add some files from outside the container in this directory. The error message then is:

Error response from daemon: extraction point is not a directory

Any help is much appreciated. Thank you.

I think I found something.

My docker create statement is as follows:

docker create --name=jenkins-Build_csc-204 --rm=true -v /cad/:/cad/ -e JOB_DIR=/home/user8/workdir/Build_csc -e PARAMETER_DIR=Parameter --volumes-from another_docker_container my_docker_image

It is meant to mount volumes from another container, in order to share files and computation results.
If I omit the --volumes-from option the mounting of /home/user8/workdir works correctly again. Files can be placed using docker cp and the container behaves normally (until the part where it wants to access the shared volume).

So the problem must lie with the shared volumes. (And the error message is not pointing to the source of the problem…)
Reference to the discussion that lead me to the root cause: https://github.com/moby/moby/issues/34167 This article is about docker on Windows, however I am running my solution on a Linux machine.

Fixed it by fixing the volumes that my docker container is using, I am now able to access the other directories in the container as well.

Hi there! im experiencing the same error but i can’t solve it. I’m running on a Linux Vm.

Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/home/ubuntu/Descargas/scripts/assets/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/ebbbe053a9670b801ef0119f4502630a618268fe87c586d2cd2cb8423142d737/merged\\\" at \\\"/var/lib/docker/overlay2/ebbbe053a9670b801ef0119f4502630a618268fe87c586d2cd2cb8423142d737/merged/etc/nginx/nginx.conf\\\" 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: failed to start containers: sandbox-proxy
mysql

Could you help me with that?
thank you so much!

I only experienced the problem, when using --volumes-from=another_container but never with -v=hostDir:containerDir.

So, my fix was more a workaround. Instead of mounting the volume pre-created by another docker container, my solution now relies on docker cp. Well knowing, that this approach is not applicable for all situations, where you need to communicate interactively between multiple containers.
Example:

docker create jenkins-Build_csc-204
docker cp hostDir:jenkins-Build_csc-204/containerDir
docker start jenkins-Build_csc-204
docker cp jenkins-Build_csc-204/containerDir:hostDir

Hope that helps. Cheers.

Hi

Could you please change the sequence of docker file to run

RUN groupadd -r developer -g 1001 &&\
	useradd -r -g developer -d /home/user8 user8

instead of running mkdir

 -p /home/user8

I think that will help

Getting the following error:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting “/etc/pki/keystores/jsd-consumer-service-0002-keystore” to rootfs at “/var/lib/docker/overlay2/768ce1bd9f465eb01eecc936c8c8381cfc4e5d8add15402a41b3010c9a662bd5/merged/jsd/jsd-consumer/conf/consumer.jks” 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 response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: rootfs_linux.go:60: mounting “/etc/pki/keystores/jsd-consumer-service-0002-keystore” to rootfs at “/var/lib/docker/overlay2/768ce1bd9f465eb01eecc936c8c8381cfc4e5d8add15402a41b3010c9a662bd5/merged/jsd/jsd-consumer/conf/consumer.jks” 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: failed to start containers: jsd

ls -alrth /etc/pki/keystores/jsd-consumer-service-0002-keystore
total 0
drwxr-xr-x. 4 root root 79 Mar 25 18:40 …
drwxr-xr-x. 2 root root 6 Mar 25 18:40 .

ls -alrth /var/lib/docker/overlay2/768ce1bd9f465eb01eecc936c8c8381cfc4e5d8add15402a41b3010c9a662bd5/
total 16K
-rw-r–r–. 1 root root 492 Mar 25 18:40 lower
-rw-r–r–. 1 root root 26 Mar 25 18:40 link
drwxr-xr-x. 2 root root 6 Mar 25 18:40 diff
drwx-----x. 41 root root 4.0K Mar 25 18:40 …
drwx------. 3 root root 18 Mar 25 18:40 work
drwx-----x. 4 root root 55 Mar 25 18:40 .

So it appears like the entire “merged” directory is missing, but I’m not sure why? Is there something I need to do before mounting to create the “merged” directory?