[Bug]: Docker-compose volume file source mounting as directory
Description
When attempting to mount a file with docker-compose, Coolify mounts as a directory instead.
Minimal Reproduction (if possible, example repository)
Example docker-compose.yml
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- prometheus_data:/prometheus
- type: bind
source: ./config/prometheus.yml
target: /etc/prometheus/prometheus.yml
is_directory: false
Issue occurs when following Coolify documentation, including with is_directory:false, and with the less verbose
volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml
Workaround:
Project -> Configuration -> Storages -> Find Directory Mount & Convert to File -> Copy and paste file -> Save & redeploy
Exception or Error
Result:
Error:
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/data/coolify/applications/jw8088gk80s0o44c8ogsoc4w/config/prometheus.yml" to rootfs at "/etc/prometheus/prometheus.yml": mount /data/coolify/applications/jw8088gk80s0o44c8ogsoc4w/config/prometheus.yml:/etc/prometheus/prometheus.yml (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: 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
Version
v4.0.0-beta.331
Cloud?
- [ ] Yes
- [X] No
Possible duplicate of https://github.com/coollabsio/coolify/issues/3303
I have the same problem
This did not used to be a problem for me, but with the recent update, Coolify started converting all of my local mounted files into named volumes. This is very frustrating, it has broken my deployment.
# pre-coolify
volumes:
# Reference https://github.com/rndmcnlly/brace/blob/main/compose.yaml for the following:
- ./some_local_file.sh:/app/backend/some_local_file.sh:ro
- ./some_local_file.py:/app/backend/some_local_file.py:ro
# coolify's rendered compose
volumes:
- '/data/coolify/applications/nkkccoo0skgsk80g048okowg/some_local_file.sh:/app/backend/some_local_file.sh'
- '/data/coolify/applications/nkkccoo0skgsk80g048okowg/some_local_file.py:/app/backend/some_local_file.py'
As of this week, I see some_local_file.sh is a directory, which I did not before.
Reproducing the same on v4.0.0-beta.393
@peaklabs-dev any chance these issues related to docker volumes can be fixed? Seems it's been around for a very long time (since v4.0.0-beta324)
Update: upgraded to v4.0.0-beta394 and I'm no longer facing this issue. As long as I create the file on the disk before adding it as a mount in the docker-compose.yml then it works fine on my side now with this version.
If the file does not exist on the disk, then a directory will be created by default (which I think is the normal behaviour of docker-compose, not coolify). I just tried this today by setting up a fresh docker-compose service and mounted a file without issue.
Try adding content: "" at the end. This somehow worked for me
Example:
- type: bind
source: ./srv/templates/sites/legacy.conf.template
target: /etc/nginx/conf.d/legacy.conf.template
is_directory: false
content: ""
i tried suggestions above, and am still getting this issue. (version: v4.0.0-beta.398, cloud: yes)
I found something that seems to work. If you toggle the setting Preserve Repository During Deployment to on, everything will suddenly work correctly, and the file will be mounted properly.
I found something that seems to work. If you toggle the setting
Preserve Repository During Deploymentto on, everything will suddenly work correctly, and the file will be mounted properly.
This will not allow coolify to create its own unique volume and keep our docker compose content as it is. You can also view that from general page. So this is a solution.
Same issue, for now used Preserve Repository During Deployment, but feels dirty