I have watchtower to keep my 50 production docker containers up to date. So far I have never had to resort to an old image since the new one was bugged but I know of the risks and dont have the --cleanup flag activated so I could easily spin up the old image if necessary. I also keep daily (mirrored) backups so I should be ok in the case of failure.

But I keep running into space issues due to multiple GBs of old images that I have to manually remove to not fill up the rather small ssd.

Does anyone have an idea how to automatically remove all but the newest unused docker image so I can quickly revert to it in case of failure but once there is another unused one of this container it goes away?

It’s probably no big deal but searching for it together with watchtower didnt yield anything so far.

Thanks in advance and have a good one.

  • phrogpilot73@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    10 months ago

    Not to sound flippant, but it seems like a solution looking for a problem. I use the --cleanup flag, and if there’s an issue, rolling back is as simple as changing dockerimage:latest to dockerimage:version that worked.

    Unless I’m missing something.

    • ssdfsdf3488sd@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      Pretty much this. I don’t even bother with watchtower anymore. I just run this script from cron pointed at the directory I keep my directories of active docker containers and their compose files:

      #/bin/sh for d in /home/USERNAME/stacks/*/ do (cd “$d” && docker compose pull && docker compose up -d --force-recreate) done; for e in /home/USERNAME/dockge/ do (cd “$e” && docker compose pull && docker compose up -d --force-recreate) done;

      docker image prune -a -f

    • ShortN0te@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      I agree. If OP is scared that the image creator is clearing the old images, then OP should just mirror the registry or just have a system backup.