'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?
Solution 1:[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
Solution 2:[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...
- mount minikube
- 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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | SCcagg5 |
Solution 2 | rambossa |