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.

RAM-Disk for Docker status/log files

Featured Replies

For 7.0.0-beta.1
For 7.0.0-beta.2
For 7.0.0-beta.3 & 4 & RC-1 & RC-2

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 7.0.0-beta.4
# -------------------------------------------------

# check compatibility
echo -e "5c359d63bcbd1e44299c8c9bafae7776 /etc/rc.d/rc.docker\n599b889ae544489329bfa813fd6e3765 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

Edited by Mainfrezzer
Edit for RC-2

  • 3 weeks later...
  • Replies 110
  • Views 30k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • Mainfrezzer
    Mainfrezzer

    6.12.7-rc2 As before, will update as we go along. 6.12.10 up to 6.12.13   # ------------------------------------------------- # RAM-Disk for Docker json/log files v1.6 for 6.12.10 # ---------

  • Mainfrezzer
    Mainfrezzer

    For 6.12.5-rc1 will update/edit this post as we go along For 6.12.5 (Does work with 6.12.6 aswell)   # ------------------------------------------------- # RAM-Disk for Docker json/log fil

  • Mainfrezzer
    Mainfrezzer

    For 7.0.0-beta.1 For 7.0.0-beta.2 For 7.0.0-beta.3 & 4 & RC-1 & RC-2 # ------------------------------------------------- # RAM-Disk for Docker json/log files v1.6 for 7.0.0-beta.4 #

Posted Images

6.12.11 released, can I safely update or do I need to wait for an update on this script?

It's fine as is.

Totally forgot to check 6.12.11 😅

 

But as stated, it does indeed run with the 6.12.10 one. Nothing has changed.

I'm using this script for a while now and completly forgot to update it. Still using the version 1.4 with unraid 6.12.11 and i have no errors in logs.

  • 1 month later...

Has anyone checked this with 6.12.13?

Still fine.

  • 1 month later...

Can anyone tell me what I'm doing wrong with this? Running on 6.12.13 I get

docker: Error: RAM-Disk Mod found incompatible files: 60ad47ed6cadcd544f92bd012d30a4f2 /etc/rc.d/rc.docker 99915e9e302b0df53cb3739951f4e33f /usr/local/emhttp/plugins/dynamix/scripts/monitor

 

Edited by PhilBarker

Read back and use the right script for your unraid version.

I am 

I'm using this one 

which says it works for 6.12.13 - but it does not on mine

You're sure you're not somehow running it twice?

On 10/13/2024 at 9:15 PM, Kilrah said:

You're sure you're not somehow running it twice?


🤦‍♂️you sir are a legend

yes of course I had - I ran it in background whilst watching syslog but never saw any output or success message
so ran it again and it error'd - so thought it wasn't working (pro-tip, doing this late at night after a zfs resilver from a failed drive, probably not wise lol)

when I checked today I saw the backup messages every 30 minutes in syslog, so I stopped docker, restarted, all working as it should

thank you 🙂

  • 1 month later...

6.12.14 & 6.12.15
 

  

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 6.12.14
# -------------------------------------------------

# check compatibility
echo -e "2f2d694da7840ead41587288ea36c9b5 /etc/rc.d/rc.docker\n9f0269a6ca4cf551ef7125b85d7fd4e0 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

 

Edited by Mainfrezzer
6.12.15

  • 2 weeks later...
On 3/8/2023 at 1:49 AM, mgutt said:

create a script with the user scripts plugin which gets only executed on first array start (check the unraid version info in the script, maybe it was updated some pages later):

Use the execute in the background button, to install the script the very first time. Now go to settings > docker and set docker to "no" and then to "yes" again.

 

ZFS mirror SSD cache pool. New SSD installed last week, only 9GB files on cache pool, but already 180GB written according to SMART report. (100GB of which is in the recent few days, meaning after 'Mover' moving data from Array to Cache)
Docker settings

Enable container table readmore-js:Yes
Docker vDisk location: (btrfs vDisk)
/mnt/user/system/docker/docker.img
Default appdata storage location:
/mnt/user/appdata/
Docker LOG rotation: Enabled, Set to 10M


I did exactly this:

0. Set all docker containers to --no-healthcheck

1. Disable Docker service.

2. Created a user script, set "At Startup of Array", copied the latest script for 6.12.14 (matched my version), save the script, click run in background. The user scripts log shows "Script Starting , then Script Finished"
3. Enable Docker service.

But I still see writes of 500+ kb to cache SSD every 5 - 10 secs.
What can I do now? I am seeking suggestions. Thanks!
 

df -h /var/lib/docker/containers
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            16G  9.9M   16G   1% /var/lib/docker/containers

 

Edited by jena

Do you see "Ram-Disk enabled" in syslog, and then "backup of ramdisk" every half hour?

 

This only affects what is logged through Docker, some containers log to their own files sparately from that, some actually do things and need to write their output... You'll never have zero writes.

Edited by Kilrah

On 12/6/2024 at 3:55 AM, Kilrah said:

Do you see "Ram-Disk enabled" in syslog, and then "backup of ramdisk" every half hour?

 

This only affects what is logged through Docker, some containers log to their own files sparately from that, some actually do things and need to write their output... You'll never have zero writes.

Yes, I do see "Success: Backup of RAM-Disk created." every half hour.

So it's working fine and your writes come from somewhere else.

On 12/7/2024 at 12:01 PM, Kilrah said:

So it's working fine and your writes come from somewhere else.

If I stop all docker containers, the write to cache pool stops.
 

11 hours ago, jena said:

If I stop all docker containers, the write to cache pool stops.
 

Precisely suggests one or more containers are writing files of their own, as mentioned this is only about logs that go through the Docker system.

  • 2 weeks later...
On 12/9/2024 at 4:00 AM, Kilrah said:

Precisely suggests one or more containers are writing files of their own, as mentioned this is only about logs that go through the Docker system.

I narrowed down to just one docker image, Omada Controller.

I was wondering if I can map the "host path 3" for the container 

/mnt/user/<path_to_docker_data>/omada_controller/logs/

to the same ramdisk that the OP's script created. 

 

Thanks!

if the logs arent *that* important, you can just map them to /tmp or /dev/shm or use the docker method with 

 

 --mount type=tmpfs,destination=/WHERE-THE/LOGS-ARE-INSIDE-THE-CONTAINER/logs/,tmpfs-mode=777,tmpfs-size=128000000

 

 

Edit: And if youre as crazy as i am, and decided to run a database in ram, you can manually edit the script similar to my that syncs on start and stop of the array

hihi.thumb.PNG.48bf6f1e6bf2260374274d7a72b1bbf2.PNG

 

Edited by Mainfrezzer

  • 3 weeks later...

7.0.0
 

  

# -------------------------------------------------
# RAM-Disk for Docker json/log files v1.6 for 7.0.0
# -------------------------------------------------

# check compatibility
echo -e "5c359d63bcbd1e44299c8c9bafae7776 /etc/rc.d/rc.docker\n599b889ae544489329bfa813fd6e3765 /usr/local/emhttp/plugins/dynamix/scripts/monitor" | md5sum --check --status && compatible=1
if [[ $compatible ]]; then

  # create RAM-Disk on starting the docker service
  sed -i '/nohup/i \
  # move json/logs to ram disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  mountpoint -q /var/lib/docker/containers || mount -t tmpfs tmpfs /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be mounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk created' /etc/rc.d/rc.docker

  # remove RAM-Disk on stopping the docker service
  sed -i '/tear down the bridge/i \
  # backup json/logs and remove RAM-Disk\
  rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
  umount /var/lib/docker/containers || logger -t docker Error: RAM-Disk could not be unmounted!\
  rsync -aH --delete ${DOCKER_APP_CONFIG_PATH%/}/containers_backup/ /var/lib/docker/containers\
  logger -t docker RAM-Disk removed' /etc/rc.d/rc.docker

  # Automatically backup Docker RAM-Disk
  sed -i '/^<?PHP$/a \
  $sync_interval_minutes=30;\
  if ( ! ((date("i") * date("H") * 60 + date("i")) % $sync_interval_minutes) && file_exists("/var/lib/docker/containers")) {\
    exec("\
      [[ ! -d /var/lib/docker_bind ]] && mkdir /var/lib/docker_bind\
      if ! mountpoint -q /var/lib/docker_bind; then\
        if ! mount --bind /var/lib/docker /var/lib/docker_bind; then\
          logger -t docker Error: RAM-Disk bind mount failed!\
        fi\
      fi\
      if mountpoint -q /var/lib/docker_bind; then\
        rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers && logger -t docker Success: Backup of RAM-Disk created.\
        umount -l /var/lib/docker_bind\
      else\
        logger -t docker Error: RAM-Disk bind mount failed!\
      fi\
    ");\
  }' /usr/local/emhttp/plugins/dynamix/scripts/monitor

else
  logger -t docker "Error: RAM-Disk Mod found incompatible files: $(md5sum /etc/rc.d/rc.docker /usr/local/emhttp/plugins/dynamix/scripts/monitor | xargs)"
fi

Nothing has changed since the beta 3 -> rc-2 script. Just reposting it as it supersedes the 6.12.14 one

  • 2 weeks later...

Thank you for create script work and being source for really useful RAM-Disk for Docker logs.

 

Would it be possible to extend(or separate script/plugin) this ram-disk support for the Plex dockers database folder.

For me the remaining unneccesary writes to appdata are from plex mediaserver and they happen every 30 seconds constantly.

It happens to specific file but ramdisking that whole folder would help. So far i havent figured out the root cause of those constant "modify" actions. all regular healtchecks and scheduled actions in plex are off.

 

Thu Jan 23 19:14:48 2025 MODIFY /mnt/user/appdata/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/ com.plexapp.plugins.library.db-wal

....

Thu Jan 23 19:16:18 2025 MODIFY /mnt/user/appdata/plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/ com.plexapp.plugins.library.db-wal

  • Author
54 minutes ago, VeixES said:

For me the remaining unneccesary writes to appdata are from plex mediaserver and they happen every 30 seconds constantly.

Did you already disable healthcheck? Maybe this stops those writes.

 

You have to add --no-healthcheck to extra parameters:

 

 

Screenshot_20250123_191122.thumb.png.871c742f19e7214096929c11d44c062c.png

 

I have it with some extra stuff.

--no-healthcheck --log-driver syslog --log-opt syslog-address=udp://127.0.0.1:541

 

Unfortunately no help. Thats why RAM-Disk seems to be easiest to reduce those writes.

Edited by VeixES

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.