Is there a straightforward way to copy files from a local machine into a docker container within a VM instance on Google Compute Engine?
I know gcloud compute ssh --container=XX
is an easy way to execute commands on a container, but there's no analogous gcloud compute scp --container=XX
. Note: I created this VM and docker container with the command gcloud alpha compute instances create-from-container ...
Note, better than just being able to transfer files, it would be nice to have an rsync
type functionality.
I generally use an approach where I use object storage in-between local machines and a cloud VMs. On AWS I use s3 sync
, on Google you can use gsutil rsync
First the data on a 'local' development machine gets pushed into object storage when I'm ready to deploy it.
Then the VM pulls content from object storage using s3 sync
. I think you can do the same with gsutil
to pull data from Google object storage into a Google container. (In fact it seems you can even rsync between clouds using gsutil).
This is my shoestring dev-ops environment. It's a little bit more work, but using object storage as a middleman for syncing snapshots of data between machines provides a bit of flexibility, a reproducible environment and peace of mind.
Unfortunately, looks like it's not available without some setup on your part (and it's not in beta): creating a volume map notwithstanding, you could do it by running sshd inside the container listening on it's own port mapped to the host:
gcloud compute firewall-rules create CONTAINER-XX-SSH-RULE --allow tcp:2022 --target-tags=XX-HOST
gcloud compute scp --port 2022 --recurse stuff/ user@XX-HOSTNAME:
or
scp -r -P 2022 stuff/ user@xx-host-ip: