Cannot start service web: OCI runtime create failed:

jemz picture jemz · Aug 27, 2019 · Viewed 20.3k times · Source

can I ask some help please when I execute the command docker-compose up -d

I get error can you help me how can I execute php using nginx

Removing nginx-container
mysql-container is up-to-date
php-container is up-to-date
Recreating 2e6f7b9915c6_nginx-container ... error

ERROR: for 2e6f7b9915c6_nginx-container  Cannot start service web: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/host_mnt/c/webdock/firstweb/default.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged\\\" at \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged/etc/nginx/conf.d\\\" 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 web  Cannot start service web: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/host_mnt/c/webdock/firstweb/default.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged\\\" at \\\"/var/lib/docker/overlay2/8261a085184069473ca52f3ad508386e84f0636baafbbc754e1447ea72427433/merged/etc/nginx/conf.d\\\" 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.

Here is my docker-compose

version: "3.7"
services:

  web:
    image: nginx:latest
    container_name: nginx-container
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www/firstweb
      - ./default.conf:/etc/nginx/conf.d/
    links:
      - php

  php:
    image: php:7-fpm
    container_name: php-container
  db:
    image: mysql
    container_name: mysql-container
    command: --default-authentication-plugin=mysql_native_password
    volumes:
      - ./mysql-data:/var/lib/mysql
    expose:
      - 3306
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: rootpass

and my default.conf

server {
        listen  80;
         index index.php;
         server_name app.dev;
         error_log  /var/log/nginx/error.log;
         access_log /var/log/nginx/access.log;
         root /var/www/firstweb;

         location ~ \.php$ {
                 try_files $uri =404;
                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
                 fastcgi_index index.php;
                 fastcgi_pass php:9000;
                 include fastcgi_params;
                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                 fastcgi_param PATH_INFO $fastcgi_path_info;
             }
     }

Answer

LinPy picture LinPy · Aug 27, 2019

change this - ./default.conf:/etc/nginx/conf.d/ to :

- ./default.conf:/etc/nginx/conf.d/default.conf

you can see in the error that Docker trying to mount a file default.conf to a folder conf.d