Network mounted filesystem for Docker

image

Did you manage to solve this problem? I am also having this in a container.

I wonder if I have to create a user in my NAS that matches a user in the docker container for it to be able to write properly. Currently, my share is mounted as the user 'pi'.

No, I did not.

Good news bro! I found a solution.

I did this because I am running the Pi with an 8GB SD card and I plan to run many containers in it.

Solution: I moved the whole docker file structure to my samba share in the NAS and sym-linked it.

Here's how you do it.

  1. Stop Docker completely

    sudo service docker stop

  2. Check which other docker processes are running:

    sudo ps faux | grep docker

  3. Kill said processes:

    sudo kill <ProcessID>

  4. Back up existing docker:

    sudo tar -zcC /var/lib docker > /NAS/MOUNTED/SHARE/PATH/dockerBackup.tar.gz

  5. Move existing docker to File Share (You might see a lot of errors related to symbolic links, it's OK)

    sudo mv /var/lib/docker /Docker

  6. Make a symlink to the fileshare

    sudo ln -s /NAS/MOUNTED/SHARE/PATH/docker /var/lib/docker

  7. Check that it is correct now

    sudo ls -al /var/lib/docker/

  8. Restart docker

    sudo service docker start

Here's the result in my NAS:

image

Permission wise, there's no difference. I have the NAS fileshare mounted using a user that has read/write permissions for that share.

Oof, that's going to slow as a snail and fraught with issues.

Save your sanity and just get a bigger SD Card.

It is very possible. However, it is running smoothly so far.

Additionally, it allows me to back up my whole docker configuration in a raided, storage grade device instead of the SD card. :wink:

And now your Docker installation is based on a networked filesystem. Did you update the docker daemon to know that it's not on a local filesystem?

No sir, I did not make changes to the daemon. It believes it is working on a local filesystem and is using the same path.

How have you mounted the remote filesystem? What protocol?

Edit: Ah, SAMBA with a symbolic link. I don't think SMB mounts will work well with needed capabilities. Great to try it but I don't think it's going to do anything but cause headaches.

"Edit: Ah, SAMBA with a symbolic link. I don't think SMB mounts will work well with needed capabilities. Great to try it but I don't think it's going to do anything but cause headaches."

Feel free to delete this thread, sir. It won't let me.