Iotedge: Remove unused images

Created on 26 Mar 2019  路  6Comments  路  Source: Azure/iotedge

In CI/CD, customers always push newer tags of images to container registries, then those images will be pulled down to target IoT Edge devices and start running.
But those images with old tags will never get removed, which will cause disk full error eventually.

app customer-reported enhancement iotedge

Most helpful comment

@shizn One way to deal with this is to use sudo docker images prune -a which removes all images that don't have any running or saved containers referencing them.

You add this to cron job (or Windows Scheduled Task) to periodically run this automatically. For e.g. (on Linux):

$ sudo crontab -e ... and adding line 0 3 * * * /usr/bin/docker image prune -a -f will run this job as root at 3AM everyday.

Would this method meet your requirement?

All 6 comments

@shizn One way to deal with this is to use sudo docker images prune -a which removes all images that don't have any running or saved containers referencing them.

You add this to cron job (or Windows Scheduled Task) to periodically run this automatically. For e.g. (on Linux):

$ sudo crontab -e ... and adding line 0 3 * * * /usr/bin/docker image prune -a -f will run this job as root at 3AM everyday.

Would this method meet your requirement?

Yep. To me, it looks like a workaround. If customers can ssh to IoT Edge devices, they can certainly use whatever the method to remove the images.
The point here is to do a reliable deployment, which means somehow we can detect potential disk full error before send the deployment manifest to IoT Hub.
I am more thinking if there is an configuration or policy in edgeAgent to deal with this, or something we can do with Device Streams. On one hand, we can delete unused images, on the other hand, we can calculate the overall images sizes of the entire IoT Edge app, and compare the remaining storage reported by IoT Edge runtime.

Does this workaround work on a windows machine with moby? Docker cli seems connect to the "normal" docker and not iotedge moby docker.

Okay found a way:

$env:DOCKER_HOST="npipe:////./pipe/iotedge_moby_engine"
docker image prune -a

Please file or vote for additional feature enhancements at https://feedback.azure.com/forums/907045-azure-iot-edge.

After I did this, it starts " Pulling image mcr.microsoft.com/azureiotedge-agent:1.0..." on next boot / restart.
That could get expensive if you're on a metered connection.

Was this page helpful?
0 / 5 - 0 ratings