named volume vs bind mounts


corgan

Recommended Posts

Hello,

 

we tried for weeks to get compreface working on Unraid Docker. I asked for help about this some month ago, but sadly the unraid docker was not out of the box capable to handle the app structure, as we discussed here.

The Developer was so kind to rewrite the structure and made a single dockerfile version for unraid and home assistant user.

I could create a Template for the normal and the GPU Version.

 

But we have the problem, that the developers used named volumes. If i try to expose the folder to make it persistent, the app can't start.

We can only use the app without persistent data, which is not ideal.

 

He explained the problem over at github quite well. Read the conversation on Github for better readability..


 

@corgan2222 in my example I used named volume:
-v compreface-db:/var/lib/postgresql/data
The default behavior of named volume is that when it first created the volume, docker copies all content of the image to the volume with all permissions. Docker in its documentation recommends using named volumes because of portability.

When you set the exact folder to mount, docker created a bind mounts:
-v '/mnt/user/appdata/compreface':'/var/lib/postgresql/data':'rw'
By default, docker does not copy image content into bind mounts. This is why the Postgres data folder is empty inside your container and Postgres can't start.

So I would follow docker recommendations and use named volumes. In case this is impossible or you still prefer using binding to a folder, there is a workaround for such case if you still want to mount the exact folder into the docker container:
You need to create a named bind mount:

docker volume create --driver local \ --opt type=none \ --opt device=/mnt/user/appdata/compreface \ --opt o=bind \ compreface-db

And then use it as named volume during start:
docker run -it --name=CompreFace -v compreface-db:/var/lib/postgresql/data -p 8000:80 exadel/compreface:0.6.1

 

Maybe I miss some essential details here.

What are the options to get the app running in the unraid docker, with persistent data (and without docker compose)

It would be great to have some Dev Comments on this. Thanks greetz Stefan

  • Like 1
Link to comment

So the way that i have seen others handle this in the past, and the way i have built unRAID style containers, is to not pre-populate mount directories at build time. Rather the default files are placed in another directory and the entrypoint script or scripts check the mount point at runtime and copy the default files in if they do not already exist. 

  • Like 1
Link to comment
3 hours ago, primeval_god said:

So the way that i have seen others handle this in the past, and the way i have built unRAID style containers, is to not pre-populate mount directories at build time. Rather the default files are placed in another directory and the entrypoint script or scripts check the mount point at runtime and copy the default files in if they do not already exist. 

 

This can be a solution. But the Dockerfile are developed by the app developer, so he has to make these changes?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.