Local mode image cleanup

Perhaps I’m doing something wrong, but is this the expected behavior?

When doing local mode dev, there doesn’t see to be any docker image cleanup which unexpected lead to a whole lots of dead images taking up space.

Is there a technique for clearing images that are replaced with new images during local dev?

root@703fdb0:~# balena images
REPOSITORY                                                       TAG                IMAGE ID       CREATED         SIZE
local_image_powermanager                                         latest             7e0f92992b79   2 minutes ago   940MB
<none>                                                           <none>             9b9ff3515a52   17 hours ago    940MB
<none>                                                           <none>             823344467a76   22 hours ago    940MB
<none>                                                           <none>             5cbdd335f59d   22 hours ago    940MB
<none>                                                           <none>             70ccbcc953bb   23 hours ago    940MB
<none>                                                           <none>             46a0dc896070   23 hours ago    940MB
<none>                                                           <none>             ab25829659e3   23 hours ago    940MB
<none>                                                           <none>             dcd12d639dbc   35 hours ago    940MB
<none>                                                           <none>             35f588457093   37 hours ago    940MB
<none>                                                           <none>             c7928ec4b7da   37 hours ago    940MB
<none>                                                           <none>             c332336db49c   42 hours ago    940MB
<none>                                                           <none>             7bc6bb4df41f   45 hours ago    940MB
local_image_basicstation                                         latest             2366d79f1b36   46 hours ago    169MB
<none>                                                           <none>             271ac7acf507   46 hours ago    802MB
<none>                                                           <none>             20694f5401b5   46 hours ago    885MB
<none>                                                           <none>             1f6a709fa180   47 hours ago    885MB
<none>                                                           <none>             969662b11c7c   47 hours ago    881MB
<none>                                                           <none>             a85b5f18ac07   2 days ago      169MB
<none>                                                           <none>             ada16281b42b   2 days ago      802MB
<none>                                                           <none>             938455f21f34   2 days ago      885MB
<none>                                                           <none>             04dcb6858cb7   2 days ago      885MB
<none>                                                           <none>             08263a5a8940   2 days ago      885MB
<none>                                                           <none>             92a269f811ec   2 days ago      300MB
<none>                                                           <none>             0c30b8092c57   2 days ago      298MB
<none>                                                           <none>             bedc054f9630   2 days ago      298MB
<none>                                                           <none>             c4c6e8030893   2 days ago      337MB
<none>                                                           <none>             5103212ec221   2 days ago      337MB
<none>                                                           <none>             96440ab84bdd   2 days ago      880MB
<none>                                                           <none>             58738194e203   2 days ago      880MB
<none>                                                           <none>             bf625d6115ea   2 days ago      880MB
<none>                                                           <none>             aadf1c0772b0   2 days ago      878MB
<none>                                                           <none>             af54e6467bf2   2 days ago      878MB
<none>                                                           <none>             929abd2bb389   2 days ago      169MB
<none>                                                           <none>             e465f73c65ce   3 days ago      169MB
<none>                                                           <none>             ddc7f91578a6   3 days ago      802MB
balenalib/raspberrypicm4-ioboard-ubuntu-python                   3.8                5d62b534249c   5 days ago      300MB
balenalib/raspberrypicm4-ioboard-debian-python                   3.7-sid            2fb3443c239d   10 days ago     298MB
balenalib/raspberrypi4-64-python                                 3.7-latest-build   c77acbe52a98   10 days ago     881MB
balenalib/raspberrypicm4-ioboard-python                          latest             6ecd3dc89499   10 days ago     337MB
balenalib/aarch64-debian-python                                  3-run              6fabbc34114b   2 weeks ago     265MB
balenalib/aarch64-debian-python                                  3-build            a2752a4b8b1b   2 weeks ago     878MB
balenalib/aarch64-debian                                         buster-run         ce7330c432ff   2 weeks ago     115MB
balenalib/aarch64-debian                                         buster-build       ddc2d25f2126   2 weeks ago     642MB
registry2.balena-cloud.com/v2/de5a844db8d3ea876e89eaa00f3acddc   latest             188df770e32d   3 months ago    68.4MB
balena/aarch64-supervisor                                        v12.11.0           b7b6ead1c4b6   7 months ago    72.7MB
balena-healthcheck-image                                         latest             18e5af790473   8 months ago    9.14kB
root@703fdb0:~# balena ps
CONTAINER ID   IMAGE                                                            COMMAND                  CREATED         STATUS                  PORTS     NAMES
961a6c817c14   271ac7acf507                                                     "/bin/sh -c 'while t…"   2 minutes ago   Up 2 minutes                      xenodochial_sutherland
4ec2c8d958e9   7e0f92992b79                                                     "/usr/bin/entry.sh /…"   2 minutes ago   Up About a minute                 powermanager_2_1_localrelease
337a06567eb6   2366d79f1b36                                                     "/usr/bin/entry.sh b…"   46 hours ago    Up 26 hours                       basicstation_1_1_localrelease
f47fa142671b   registry2.balena-cloud.com/v2/de5a844db8d3ea876e89eaa00f3acddc   "/usr/src/app/entry.…"   2 weeks ago     Up 26 hours (healthy)             balena_supervisor

As a hack, I noticed if I go back to the web console and turn off local mode, it removes all those dead images, clearing the slate… Then I flip it back to local mode and start again.
There’s probably a better way though right?

1 Like


You can log into the Host OS and run balena image prune to get rid of older images.

I’m not 100% sure, but I think this might also cause your next build to be slower as it has to fetch intermediate images.

Thanks @TJvV that seems to be exactly what I needed

Thank you @TJvV and @barryjump