openshifteclipse-che

How do I load a dockerimage in eclipse-che?


I'm trying to load a docker-image on openshift.io so I attempt to just use 'hello-world' as my docker image, this is my 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

However I get this error Error: Failed to run the workspace: "The following containers have terminated: hello-world: reason = 'Completed', exit code = 0, message = 'null'" This doesn't happen with the custom images provided by eclipse, so what do I need to change in order to get a docker-image work on openshift.io? as far as I know, I can't edit the "Dockerfile", I can only pull images from a docker registry.


Solution

  • The command attribute of the dockerimage along with other arguments, is used to modify the entrypoint command of the container created from the image. In Eclipse Che the container is needed to run indefinitely so that you can connect to it and execute arbitrary commands in it at any time. Because the availability of the sleep command and the support for the infinity argument for it is different and depends on the base image used in the particular images, Che cannot insert this behavior automatically on its own. However, you can take advantage of this feature to, for example, start necessary servers with modified configurations, and so on.

    For the dockerimage component to have access to the project sources, you must set the mountSources attribute to 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']