简体   繁体   English

Boot2Docker到Google Compute Engine VM:保存Docker容器

[英]Boot2Docker to Google Compute Engine VM: saving Docker container

I am running Boot2Docker v1.0.1 on Windows, and wish to fire up a Docker container I have created on a Google Compute Engine VM. 我在Windows上运行Boot2Docker v1.0.1,并希望启动我在Google Compute Engine VM上创建的Docker容器。

In order to do so, I need to save the container and upload it to Google Cloud Storage. 为此,我需要保存容器并将其上传到Google云端存储。 I issue the following command: 我发出以下命令:

docker save --output=mycontainer.tar mycontainer:latest docker save --output = mycontainer.tar mycontainer:latest

The command completes without error. 该命令完成且没有错误。 However, I cannot find the rce_env.tar file anywhere on my hard drive. 但是,我无法在硬盘上的任何位置找到rce_env.tar文件。

Does anyone have any experience with this? 有人对这个有经验么? If not, is there a better way to run containers on GCE VM's? 如果没有,是否有更好的方法在GCE VM上运行容器?

You can run google/docker-registry locally to push your container images to GCS. 您可以在本地运行google/docker-registry以将容器映像推送到GCS。

docker run -ti --name gcloud-config google/cloud-sdk \
  gcloud auth login
docker run -ti --volumes-from gcloud-config google/cloud-sdk \
  gcloud config set project <project>
docker run -d -e GCS_BUCKET=bucketname -p 5000:5000 \
  --volumes-from gcloud-config google/docker-registry
docker tag imagename localhost:5000/imagename
docker push localhost:5000/imagename

And then run it on GCE to pull your containers from GCS. 然后在GCE上运行它以从GCS中取出容器。

docker run -d -e GCS_BUCKET=bucketname -p 5000:5000 google/docker-registry
docker run localhost:5000/imagename

I understand that you are using boot2docker on windows. 我知道你在windows上使用boot2docker。

On a similar setup, using OSX and boot2docker 1.1.0 , the following works: 在类似的设置上,使用OSX和boot2docker 1.1.0 ,以下工作:

docker save --output mycontainer.tar mycontainer:latest

As also does redirecting standard output: 同样重定向标准输出:

docker save mycontainer:latest > mycontainer.tar

GCE now allows to store docker images for your projects using the gcloud command. GCE现在允许使用gcloud命令为您的项目存储docker镜像。

you can now run $ gcloud preview docker push gcr.io/YOUR-PROJECT/IMAGE-NAME 你现在可以运行$ gcloud preview docker push gcr.io/YOUR-PROJECT/IMAGE-NAME

Source: https://cloud.google.com/tools/container-registry/#pushing_to_the_registry 资料来源: https//cloud.google.com/tools/container-registry/#pushing_to_the_registry

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

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