Attempt to fix disk space issues by removing large docker images after they have been used. This commit backports commits from `3.4.x` that were applied to test the changes. Closes gh-42776