Is it possible to create a volume that is a file, not a directory?

I am trying to make a simple structured nginx instance with docker. Using this command below to create the container…

docker container create -v ./nginx.conf:/etc/nginx/conf.d/nginx.conf -v .:/app/ -p 80:80 docker.io/nginx

And this is the file structure of it…

- www
-------------- public
---------------------------- index.html
- nginx.conf

And this is the nginx.conf

server {
    server_name localhost;
    listen 80;
    
    root /app/www/public;

    index index.html index.htm;
    autoindex on;
}

However the index.html will not work when I go to the localhost.

When I change the docker command to this it does work however, but this will also mirror all of the files and folder from my file structure into the containers /etc/nginx/conf.d/ directory

docker container create -v .:/etc/nginx/conf.d/ -v .:/app/ -p 80:80 docker.io/nginx
  • @trymeoutOP
    link
    English
    19 months ago

    When I change the path to this…

    docker container create --name nginx -v $(pwd)/nginx.conf:/etc/nginx/conf.d/nginx.conf -v $(pwd):/app/ -p 80:80 docker.io/nginx

    It does not seem to make a difference since when I go to localhost in my browser, I am still greeted with the “Welcome to nginx!” page.