mehappy

Members
  • Posts

    8
  • Joined

  • Last visited

Report Comments posted by mehappy

  1. On 8/17/2021 at 10:09 AM, mgutt said:

    @limetech

    I solved this issue as follows and successfully tested it in:

    • Unraid 6.9.2
    • Unraid 6.10.0-rc1

     

    1. Add this to /boot/config/go (by Config Editor Plugin):
      # -------------------------------------------------
      # RAM-Disk for Docker json/log files
      # -------------------------------------------------
      # create RAM-Disk on starting the docker service
      sed -i '/^  echo "starting \$BASE ..."$/i \
        # move json/logs to ram disk\
        rsync -aH --delete /var/lib/docker/containers/ ${DOCKER_APP_CONFIG_PATH%/}/containers_backup\
        mount -t tmpfs tmpfs /var/lib/docker/containers\
        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\
        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("mkdir /var/lib/docker_bind");\
        exec("mount --bind /var/lib/docker /var/lib/docker_bind");\
        exec("rsync -aH --delete /var/lib/docker/containers/ /var/lib/docker_bind/containers");\
        exec("umount /var/lib/docker_bind");\
        exec("rmdir /var/lib/docker_bind");\
        exec("logger -t docker RAM-Disk synced");\
      }' /usr/local/emhttp/plugins/dynamix/scripts/monitor
    2. Optional: Limit the Docker LOG size to avoid using too much RAM:
      1082044065_2021-08-1910_34_09.png.30f268aeff1d17f254eacd8d1e7bf9a8.png
    3. Reboot server

     

    Notes:

    • By this change /var/lib/docker/containers, which contains only status and log files, becomes a RAM-Disk and therefore avoids wearing out your SSD and allows a permanent sleeping SSD (energy efficient)
    • It automatically syncs the RAM-Disk every 30 minutes to your default appdata location  (for server crash / power-loss scenarios). If container logs are important to you, feel free to change the value of "$sync_interval_minutes" in the above code to a smaller value to sync the RAM-Disk every x minutes.
    • If you like to update Unraid OS, you should remove the change from the Go File until it's clear that this enhancement is still working/needed!

     

    Your Reward:

    415470549_2021-08-1808_28_47.png.b552e3017be7cbf5a825f6e9d8d13885.png

     

    After you enabled the docker service you can check if the RAM-Disk has been created (and its usage):

    image.png.c52c3e62319c9f0fdbb253cb8462d785.png

     

    Screenshot of changes in /etc/rc.d/rc.docker

    763244413_2021-08-2200_03_37.thumb.png.c16142adb6acaf74f90cd37382d2c490.png

     

    and /usr/local/emhttp/plugins/dynamix/scripts/monitor

    783908454_2021-08-2200_01_57.png.7942055f5871d164050cda1f415930bc.png

    I followed this and now my log memory constantly shows 100%. Is this something to be concerned about?

    unraidmemory.PNG

     

    EDIT: this is unrelated, looks like nginx is running away with the logs

    I found another topic (unsolved) that is about this issue: https://forums.unraid.net/topic/86114-nginx-running-out-of-shared-memory/