coolify icon indicating copy to clipboard operation
coolify copied to clipboard

[Bug]: Docker-compose volume file source mounting as directory

Open nickhid opened this issue 1 year ago • 9 comments

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:

image

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

nickhid avatar Sep 10 '24 06:09 nickhid

Possible duplicate of https://github.com/coollabsio/coolify/issues/3303

kmbuthia avatar Sep 10 '24 17:09 kmbuthia

I have the same problem

allanvobraun avatar Nov 06 '24 21:11 allanvobraun

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.

LukeRouleau avatar Dec 13 '24 20:12 LukeRouleau

Reproducing the same on v4.0.0-beta.393

em230418 avatar Feb 17 '25 09:02 em230418

@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)

kmbuthia avatar Feb 17 '25 12:02 kmbuthia

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.

kmbuthia avatar Feb 17 '25 19:02 kmbuthia

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: ""

Day-OS avatar Mar 12 '25 01:03 Day-OS

i tried suggestions above, and am still getting this issue. (version: v4.0.0-beta.398, cloud: yes)

jpjagt avatar Mar 13 '25 08:03 jpjagt

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.

ar065 avatar Jun 08 '25 08:06 ar065

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.

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.

sudip-199 avatar Jul 03 '25 11:07 sudip-199

Same issue, for now used Preserve Repository During Deployment, but feels dirty

NanoBjorn avatar Aug 18 '25 13:08 NanoBjorn