Google Cloud VM映像到Docker映像 [英] Google Cloud VM Image to docker image

查看:60
本文介绍了Google Cloud VM映像到Docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个随应用程序一起安装的Google Cloud VM.安装步骤完成,然后执行以下操作:

I have a Google Cloud VM that installed with my application. The installation step is completed and I:

  1. 关闭VM实例.
  2. 将磁盘导出到名为 MY_CUSTOM_IMAGE_1
  3. 的磁盘映像
  1. Turned off the VM instance.
  2. Exported the disk to disk image called MY_CUSTOM_IMAGE_1

我现在希望使用 MY_CUSTOM_IMAGE_1 作为我的Docker映像构建的起始映像.为了生成图像,我正在使用Google Cloud Build.

My wish now is to use MY_CUSTOM_IMAGE_1 as the starting image of my docker image build. For building the images I'm using Google Cloud Build.

我的docker文件应如下所示:

My docker file should look like this:

FROM MY_CUSTOM_IMAGE_1 AS BUILD_ENV
...

当我尝试使用此图像时,出现构建错误:

When I tried to use this image I got the build error:

ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1
ERROR
pull access denied for MY_CUSTOM_IMAGE_1, repository does not exist or may require 'docker login'
Step 1/43 : FROM MY_CUSTOM_IMAGE_1 AS BUILD_ENV

原因是VM映像与Docker映像不同.

The reason is that VM images are not the same as Docker images.

是否可以在没有外部工具(GCP外部,例如"docker私有存储库")的情况下进行此转换(GCP VM映像-> Docker映像)?

Is this possible to make this transform (GCP VM Image -> Docker image), without external tools (outside GCP, like "docker private repositories")?

谢谢!

推荐答案

如果您知道VM上所有已安装的内容(以及所有命令),请在Dokerfile中执行相同的操作.用作基础映像,与当前VM的操作系统版本相同.执行一些测试,它应该很快就等效.

If you know all the installed things on your VM (and all the commands), do the same thing in a Dokerfile. Use as base image, the same OS version as your current VM. Perform some tests and it should be quickly equivalent.

如果您的VM应用程序中有全状态文件,则情况会有些复杂,您必须在容器中装入磁盘,并更新应用程序的配置以写入正确的已装入文件夹.它更复杂",但互联网上有很多例子!

If you have statefull files in your VM application, it's a little bit more complex, you have to mount a disk in your container and to update your application's configuration to write in the correct mounted folder. It's more "complex" but there is tons of example on internet!

这篇关于Google Cloud VM映像到Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆