Containers not stopped on Reboot?

Following question. I have several containers with heavy usb disk io running. I did an ax3 firmware update with reboot and after starting back up i now have corrupted files on my usb stick and the container services therefore don’t work anymore. How can this be?

My assumption was when i do a reboot RouterOS stops all the running containers beforehand, then safely ejects the USB drive and only then performs the Reboot.
It doesn’t seem like this is the case.

1 Like

It seems that ROS is just kills container processes without waiting them (or is very short wait timeout) to be properly terminated on ROS shutdown, when comparing ROS shutdown/reboot time with all running containers stop time, containers stop takes more time which concludes that container processes are ended prematurely on shutdown.
Because of this to avoid issues I’m using this script for any reboot (same can be reused for shutdown by replacing in script at end /system/reboot with /system/shutdown):

:local stopTimeoutSec 120
:local runningStatus "running"
:local stoppedStatus "stopped"

/container
:local runningContainers [find status=$runningStatus]
:if ([:len $runningContainers] > 0) do={
  :foreach i in=$runningContainers do={ stop $i }

  :local checkContainers do={
    :foreach cont in=$runningContainers do={
      :if ([get $cont status] != $stoppedStatus) do={ :return false }
    }
    :return true
  }

  :local sec 0
  :while (![$checkContainers runningContainers=$runningContainers stoppedStatus=$stoppedStatus] && $sec <= $stopTimeoutSec) do={
    :delay 1
    :set sec ($sec + 1)
  }
  :delay 2
}

/system/reboot

Also when running containers avoid performing Download&Install in System->Packages->Check For Updares which also peforms reboot, just use Download and execute script above when packages are downloaded.

1 Like

OK thank you, very helpful reply. I will use your script from here on for reboots.