Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

virtiofs: Files created by docker on unraid host not visible in guest VM until reboot (caching issue?)

Featured Replies

I'm having an issue with data written by a docker container not being visible from a guest VM that has the data storage mounted via virtiofs until the guest is rebooted.

Essentially, when docker writes data, I can't see that data in my guest OS, unless I reboot the guest.

My goal is to be able to use Unraid's docker daemon to run my containers for development, with the Debian VM between my dev workstation and the Unraid server.


My setup:

  • I created a share called development.

  • I created a new Debian VM that mounts this share using virtiofs to /development.

  • I added this fstab entry to Debian: development /development virtiofs rw 0 0.

  • I installed the docker cli to the Debian VM.

  • I added the following entry to /boot/config/docker.cfg in Unraid: DOCKER_OPTS="--storage-driver=btrfs -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375"

  • I use Remote-SSH in VS Code to connect to Debian from my development workstation.

With this setup, I can:

  • Manage Unraid docker containers from Debian and use compose

  • Store repositories in the /development directory on Debian

  • Connect to Debian from any workstation, and work off of the same dev environment

This all works great, except for one issue:

If I mount a docker volume into the development directory for persistent storage, the changes are not reflected in the Debian VM, unless I reboot (or umount and mount, I presume). This appears to be related to the virtiofs caching.

For example, if I start up an nginx container, and mount a volume from the Unraid share directory to the nginx log directory, the log files are stored, but I can't see them from Debian at the time the files are written.

Here is an example volume mount:

volumes:
	- /mnt/user/development/compose-test/data:/var/log/nginx

After nginx writes the log data to this directory/volume, you can see the Debian thinks /data is empty, while Unraid shows this directory containing files:

  • Debian:

ishmael@devserver:/development/compose-test$ ls -al

drwxrwxr-x 1 ishmael ishmael   0 Sep 19 20:42 data
-rw-rw-r-- 1 ishmael ishmael 242 Sep 19 20:46 docker-compose.yaml
  • Unraid:

root@solidsnake:/mnt/user/development/compose-test# ls -al

drwxrwxr-x 1 ishmael  1000  38 Sep 19 20:46 data/
-rw-rw-r-- 1 ishmael  1000 242 Sep 19 20:46 docker-compose.yaml

After rebooting Debian, it picks up the files in the data directory without issue. But, it doesn't catch any new writes until the next reboot.

I thought this might be a permissions issue at first, but the files written by Docker into the data directory are set with the read flag for everyone.

root@solidsnake:/mnt/user/development/compose-test/data# ls -al

-rw-r--r-- 1 root    root  2932 Sep 19 21:16 access.log
-rw-r--r-- 1 root    root 17879 Sep 19 21:31 error.log

I've tried to modify the fstab entry in Debian to mount the directory without caching cache=none, but Debian failed to boot. I also tried adding additional flags for nofail and _netdev, but the mount failed.

Example fstab troubleshooting:

development /development virtiofs rw,cache=none,nofail,_netdev 0 0

Solved by Apeiron

  • Author

This is starting to become a real problem since I can't see the file changes being performed by Docker containers in real time. Most recently I did some npm package updates, and my package.json file was updated, but I can't review the changes.

I realize my initial post was a lot of information, which isn't always the best for receiving help. I'll try to simplify this the best I can.

I have an Unraid share that is mounted to a VM using virtiofs. I've also used a bind mount to mount that same share into a Docker container. When a file changes, such as Docker writing to a file, I cannot see these changes in the VM unless I reboot the VM. Docker containers do not have this issue and see any file changes immediately. My best guess is that this is just a quirk of virtiofs, and I need to find the appropriate configuration.

Thank you for any advice. I'm going to have to switch back to local development until I resolve this issue.

  • Author
  • Solution

I think I found what I was looking for, and updates were now being reflected in the OS, but still not in real time.

In the XML for the mounted filesystem, I changed to <cache mode='none'.

```
<filesystem type='mount' accessmode='passthrough'>

<driver type='virtiofs' queue='1024'/>

<binary path='/usr/libexec/virtiofsd' xattr='on'>

<cache mode='none'/>

<sandbox mode='chroot'/>

</binary>

<source dir='/mnt/user/development/'/>

<target dir='development'/>

<alias name='fs0'/>

<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>

</filesystem>
```

Feels like my idea isn't going to work as I expected, so I just installed docker directly to my VM.

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.