0

I have a Docker image running on a VM instance, which is running in GCE (Google Cloud Engine). To extract files from the Docker image to local machine, I usually do

docker cp <DOCKER_IMG>:/root/<PATH_IN_IMG> /home/<PATH_IN_VM>

gcloud compute scp --recurse <VM_INSTANCE_NAME>:/home/<PATH_IN_VM> ~/Desktop/<LOCAL_MACHINE_PATH>

So, the files follow the path DOCKER_IMAGE -> GCE VM -> LOCAL MACHINE.

But now I have run out of space in VM and cannot add more due to free trial limitations.

Is there a way to do the copy directly DOCKER_IMAGE -> LOCAL MACHINE, without taking up space in GCE Linux VM in the meanwhile?

Any other alternative is welcome, for example copying the files DOCKER_IMAGE -> GCE VM and deleting the copied ones so that the duplicated files do not take the space in the VM environment as well as in the Docker image (docker cp and rm after cp of each one of the files).

2
  • If your VM is out of free space, it will soon crash and then you will have a bigger problem because you will not be able to login or the system will not even boot. Commented Feb 1, 2022 at 20:40
  • When trying to do something like docker exec -it <IMAGE_ID> rm -rf <SOME_DIR>, I get the error -> rm: cannot remove <FILES_IN_DIR>: No space left on device. Any idea on how I could work around this so I don't have 100% of disk full?
    – fff
    Commented Feb 2, 2022 at 10:43

0

You must log in to answer this question.