I create a GCP instance which runs automatically a docker image (gcloud beta compute instances create-with-container). Every time I reboot and there is a new image available, it is downloaded and executed, but the previous images stays "forever", until I run out of disk space.

Do I have to manually force the instance to prune old images?


These instances are nothing more but a COS (container optimized OS) with Docker installed. So, yes, you have to do it manually, just like if you would have your own VM with Docker installed.

Personally, I wouldn't want anything to be deleted from my VM automatically.

You can run the following command to achieve what you want:

docker image prune -a
  • They are something more, in the sense you specify in the instance metadata the image to be run, ENV variables and Volumes to mount. So it's weird they don't prune unused images automatically. – nunojpg May 4 '18 at 10:26
  • Well, yes. But in the end it is translated into regular Docker commands, which is executed in the VM. – suren May 4 '18 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.