I'm using Google Cloud Platform with Cloud Build and cloudbuild.yaml for software deployments. The target VM always has the Google Container Optimized OS (COS).
The basic thing we do, is to update a running docker container with a new container.
- name: 'gcr.io/cloud-builders/gcloud'
args: ['compute','instances','update-container','my-vm-id','--zone','europe-west3-c','--container-restart-policy=always','--container-image=gcr.io/cloud-02/my-vm-id','--container-mount-host-path=host-path=/var/extdata,mount-path=/var/extdata,mode=rw']
But in this case, the old docker images remain on the Host-VM. I can list them on the Host-VM with docker image list. Since the images are in /var/lib/docker, the files are stateful and are'nt gone after a restart.
So, I don't get it, how can I prune the docker image files on the Host-VM within the deployment process?