skip to Main Content

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?

2

Answers


  1. 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

    Login or Signup to reply.
  2. How are you running Docker? here’s an answer …

    For Mac with Minikube/Hyperkit docker and Docker Compose

    Since I’m not using Docker Desktop any longer, I’ve experienced numerous issues similar to "docker in docker (dind)" paradigm with minikube…

    1. mount minikube
    2. use absolute path

    e.g., easiest way was to mount the exact home path…

    minikube mount $HOME:/Users/<you>
    
    ... keeps running...
    

    docker-compose.yaml

    volumes:
          - /Users/<you>/path/to/file.yaml:/somedir/file.yaml
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search