如何在 eclipse-che 中加载 docker 镜像?

How do I load a dockerimage in eclipse-che?

我正在尝试在 openshift.io 上加载 docker 图像 所以我尝试只使用 'hello-world' 作为我的 docker 图像,这是我的 devfile

metadata:
  name: test
attributes:
  persistVolumes: 'false'
components:
  - mountSources: true
    endpoints:
      - name: hello
        port: 4200
    memoryLimit: 1Gi
    type: dockerimage
    image: 'hello-world'
    alias: hello-world
apiVersion: 1.0.0

但是我得到这个错误Error: Failed to run the workspace: "The following containers have terminated: hello-world: reason = 'Completed', exit code = 0, message = 'null'" eclipse 提供的自定义图像不会发生这种情况,所以我需要更改什么才能在 openshift.io 上获得 docker-图像?据我所知,我无法编辑“Dockerfile”,我只能从 docker 注册表中提取图像。

这看起来像是hello-world image exits的入口流程。默认情况下,您的图像不应退出,或者您应该使用不会在您的开发文件中退出的命令覆盖默认进入命令。您可以尝试将如下内容添加到 dockerimage 组件中。

     command: ['tail']
     args: ['-f', '/dev/null']

查看this example

dockerimage 的command 属性和其他参数一起用于修改从镜像创建的容器的入口点命令。在 Eclipse Che 中,容器需要 运行 无限期地连接到它并随时在其中执行任意命令。由于 sleep 命令的可用性及其对无限参数的支持是不同的,并且取决于特定图像中使用的基础图像,Che 无法自行自动插入此行为。但是,您可以利用此功能,例如,使用修改后的配置启动必要的服务器等。

要使 dockerimage 组件能够访问项目源,您必须将 mountSources 属性设置为 true。

metadata:
  name: test
attributes:
  persistVolumes: 'false'
components:
  - mountSources: true
    endpoints:
      - name: hello
        port: 4200
    memoryLimit: 1Gi
    type: dockerimage
    image: 'hello-world'
    alias: hello-world
    command: ['sleep', 'infinity']