Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative mountpoint in compose file #78

Open
Flying--Dutchman opened this issue Mar 22, 2020 · 5 comments
Open

Relative mountpoint in compose file #78

Flying--Dutchman opened this issue Mar 22, 2020 · 5 comments

Comments

@Flying--Dutchman
Copy link

Flying--Dutchman commented Mar 22, 2020

Is it possible to use relative paths in the docker-compose.yaml file?
So, something like:

version: '3' 
  services:  
    mariadb:  
        image: 'mariadb'  
        container_name: mariadb1
        environment:
            - MYSQL_DATABASE=default
        volumes:
            - data-volume:/var/lib/mysql
volumes:
   data-volume:
        driver: local-persist
        driver_opts:
            mountpoint: ./mariadb

When I execute docker-compose up ., I'm getting following error:

ERROR: for mariadb Cannot start service mariadb: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused "rootfs_linux.go:58: mounting \"/run/containerd/io.containerd.runtime.v1.linux/moby/db5c3688b835f041024a9982ec4e0d3ad8fe2f5e13a3514b410a6db74938f5a9/mariadb\" to rootfs \"/var/lib/docker/overlay2/598a206cbdf4c4a99ed293eaf7fbca8a67b61beddb901ce646a2265580bf758d/merged\" at \"/var/lib/mysql\" caused \"stat /run/containerd/io.containerd.runtime.v1.linux/moby/db5c3688b835f041024a9982ec4e0d3ad8fe2f5e13a3514b410a6db74938f5a9/mariadb: no such file or directory\""": unknown

EDIT:
local-persist was installed using the "Quick way", with the install script in README.

@CWSpear
Copy link
Collaborator

CWSpear commented Mar 22, 2020

docker-compose expands directories to the full path by default... I'll have to look closer, but it is probably the case that compose doesn't know that mountpoint is a directory, so it doesn't expand it (i.e., it's just trying to pass in to the plugin directly).

I don't think I can get the path that the docker-compose.yml is in to be able to expand it correctly myself... so at first blush, I don't think it's possible, but is probably worth digging into a bit more.

In the meantime, some systems will pass through the PWD environment variables to compose, so you can try this: mountpoint: ${PWD}/mariadb

@Flying--Dutchman
Copy link
Author

Flying--Dutchman commented Mar 22, 2020

Thats too bad, hope it will be possible in the future. Thank you very much for your help.

In the meantime, some systems will pass through the PWD environment variables to compose, so you can try this: mountpoint: ${PWD}/mariadb

Unfortunately, this is throwing the same error.
Will stick to fixed paths then.

${PWD} is working, thank you 👍

@Flying--Dutchman
Copy link
Author

Closing issue...

Problem was apparently not the dot, but an orphaned container. As it seems, relative paths are working as expacted.

Only thing ist, missing directories are not automaticly created.

@CWSpear
Copy link
Collaborator

CWSpear commented Mar 22, 2020

It does attempt to create the directory, but there are things that can happen such that it won't work:

local-persist/driver.go

Lines 110 to 116 in a8e9cdd

err := os.MkdirAll(mountpoint, 0755)
fmt.Printf("Ensuring directory %s exists on host...\n", magenta(mountpoint))
if err != nil {
fmt.Printf("%17s Could not create directory %s\n", " ", magenta(mountpoint))
return volume.Response{ Err: err.Error() }
}

You could try looking at the driver's logs (i.e. journelctl for systemd or whatever it is...) to see what the error there says.

@Flying--Dutchman
Copy link
Author

Thank you.

I noticed in Portainer, the following:

image

So, apparently relative paths, starting with a dot are not working.
When using ${PWD}, the volume creates just fine.

For the time beeing, maybe add it to the readme?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants