Cannot start service web: OCI runtime create failed
You're seeing OCI runtime create failed because Docker tried to mount a file as if it were a directory, or vice versa. In your case, the host path /host_mnt/c/webdock/firstweb/default.conf exists on the filesystem, but Docker thinks it's a file. The Nginx service expects that path to be a directory so it can drop additional .conf files there at runtime (or you're mounting a single file into a location where Nginx expects a directory tree).
The error message is explicit:
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
That means one of two things:
default.confon your host is a regular file, but Docker Compose is mounting it into/etc/nginx/conf.d/, which Nginx treats as a directory.- Or the volume mapping in
docker-compose.ymlpoints to a single file instead of a directory when you intend to mount multiple configs.
Why this happens in your setup
In your compose file:
volumes:
- ./:/var/www/firstweb
- ./default.conf:/etc/nginx/conf.d/
Docker sees ./default.conf as a single file. When you map it to /etc/nginx/conf.d/, Docker attempts to create that directory inside the container and bind-mount the host path there. If the host path is a file, the OCI runtime rejects it with "not a directory".
Nginx expects /etc/nginx/conf.d/ to be a directory containing multiple configuration snippets (e.g., default.conf, ssl.conf, etc.). Mounting a single file directly into that path breaks the expectation.
How to fix it
Option 1: Mount the entire config directory
Instead of mounting a single file, create a directory on the host and mount it as a whole:
# On the host machine where you run docker-compose up
mkdir -p firstweb/config/nginx/conf.d
mv default.conf firstweb/config/nginx/conf.d/
Then update your docker-compose.yml:
volumes:
- ./:/var/www/firstweb
- ./config/nginx/conf.d:/etc/nginx/conf.d/
This way, the host path is a directory, and Docker can mount it cleanly into the container's /etc/nginx/conf.d/. You can add more .conf files to ./config/nginx/conf.d/ on the host if needed.
Option 2: Mount only the single file (if you truly want one file)
If you intend to override the entire Nginx config with a single file, mount it to the expected location inside conf.d:
volumes:
- ./:/var/www/firstweb
- ./default.conf:/etc/nginx/conf.d/default.conf
Note that this replaces any other files Docker or Nginx might expect in /etc/nginx/conf.d/. This is fine if you're fully managing your config from there, but be careful not to break defaults you rely on.
Additional considerations
File vs directory confusion in paths
Always verify the host path type before mounting:
ls -ld ./default.conf
# or
stat ./default.conf
If ./default.conf is a file and you need a directory, create one:
mkdir -p ./config/nginx/conf.d && mv default.conf ./config/nginx/conf.d/
Host path exposure in Docker Compose
Your current volume mappings use relative paths (e.g., ., ./mysql-data). That's fine when running locally. If you run these containers on a different host or via a CI system, ensure the host paths exist and are accessible from that environment. The error output shows /host_mnt/c/webdock/firstweb/default.conf, which suggests your compose file is being interpreted with an absolute path prefix somewhere in your environment. Confirm that the actual path you reference in docker-compose.yml matches what exists on the machine executing docker-compose up.
Nginx config best practices
Your default.conf looks valid for a basic PHP-FPM setup:
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;
}
}
A few notes:
try_files $uri =404;is appropriate if you want to return 404 when the file doesn't exist. If you're using Laravel or another framework that relies on its own routing, this may not be necessary inside a PHP location block.- Make sure
index.phpexists in/var/www/firstweb. Otherwise Nginx will try to serve an index without finding it.
If you're working with Laravel projects specifically, you might prefer mounting the project root directly and letting Laravel handle routing instead of relying on try_files inside the PHP location block. For more patterns around serving Laravel in Docker, see the LaravelCompany resource for deployment guides.
Verifying the fix
After adjusting your volume mappings:
docker-compose down
docker-compose up -d
Check logs to confirm Nginx starts cleanly:
docker logs nginx-container
If you see no "OCI runtime create failed" and Nginx logs show nginx: [warn] ... or similar startup messages followed by listening on port 80, the container is healthy. If errors persist, re-check that every host path referenced in your volumes is a directory when expected and a file only when explicitly mapping a single config file.