Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose create a directory instead of mounting the file

I have a very simple docker-compose.yml file where I use nginx and mounting a file as a volume.

But everytime I run the application, it is creating a directory .htpasswd without really mounting the .htpasswd file where I locally.

This is the docker-compose.yml.

version: '3'
services:

  reverse:
    container_name: reverse
    hostname: reverse
    restart: unless-stopped
    image: nginx
    ports:
      - 80:80
      - 443:443      
    volumes:
      - ./nginx/.htpasswd:/etc/nginx/conf.d/.htpasswd

Can someone help me fix this?

like image 200
Jananath Banuka Avatar asked Nov 27 '25 01:11

Jananath Banuka


1 Answers

by default if binded to a none existent path, docker will create a folder, the solution would be in your case to create the path before running your docker-compose

like image 69
SCcagg5 Avatar answered Nov 28 '25 15:11

SCcagg5



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!