Photo by Stuart Conner.
Redditor russell_m explains:
Paint the bottom ring of your shaving cream cans with clear nail polish and they won’t leave rust rings in your bathroom.
This actually works on all sorts of things. I had a glass that was painted on the bottom and leaving marks on my wood table, and clear nail polish puts a nice layer of protection between them. Use Clear Nail Polish to Keep Metal Cans from Rusting [Reddit]