繁体   English   中英

通过 R 在 gcloud 上启动 VM Cluster (gce_vm_cluster) 时,如何在主目录中自动创建 .docker 文件夹?

[英]How can I auto-create .docker folder in the home directory when spinning up VM Cluster (gce_vm_cluster) on gcloud through R?

我在 R 中使用以下命令创建 VM:

vms <- gce_vm_cluster(vm_prefix=vm_base_name,
                      cluster_size=cluster_size,
                      docker_image = my_docker,
                      ssh_args = list(username="test_user",
                      key.pub="/home/test_user/.ssh/google_compute_engine.pub", 
                      key.private="/home/test_user/.ssh/google_compute_engine"),
                      predefined_type = "n1-highmem-2")

现在,当我通过 SSH 连接到 VM 时,我在主目录中找不到 .docker 文件夹

test_user@test_server_name:~$ gcloud beta compute --project "my_test_project" ssh --zone "us-central1-a" "r-vm3"
test_user@r-vm3 ~ $ ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .ssh

现在下面的命令给出了一个错误(..显然)

test_user@r-vm3 ~ $ docker pull gcr.io/my_test_project/myimage:version1
Unable to find image 'gcr.io/my_test_project/myimage:version1' locally
/usr/bin/docker: Error response from daemon: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication.
See '/usr/bin/docker run --help'.

我需要运行docker-credential-gcr configure-docker命令来获取文件夹/文件.docker/config.json

test_user@r-vm3 ~ $ docker-credential-gcr configure-docker
/home/test_user/.docker/config.json configured to use this credential helper for GCR registries
test_user@r-vm3 ~ $ ls -a
.  ..  .bash_history  .bash_logout  .bash_profile  .bashrc  .docker  .ssh

现在,

test_user@r-vm3 ~ $ docker pull gcr.io/my_test_project/myimage:version1
version1: Pulling from my_test_project/myimage
Digest: sha256:98abc76543d2e10987f6ghi5j4321098k7654321l0987m65no4321p09qrs87654t
Status: Image is up to date for gcr.io/my_test_project/myimage:version1
gcr.io/my_test_project/myimage:version1

我要解决的问题:我需要 .docker/config.json 出现在 VM 中,而无需通过 SSH 连接并运行docker-credential-gcr configure-docker命令

如何创建一个bash脚本,上传到一个云存储桶,并在创建集群时调用它? 你还提到了“R”你是在谈论 R 脚本吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM