简体   繁体   中英

OpenShift template with the jboss/wildfly docker image that deploys my war (binary source strategy)

In my OpenShift template, I have this BuildConfig:

  - kind: BuildConfig
    apiVersion: v1
    metadata:
      name: "webapp-build"
    spec:
      triggers:
        - type: ImageChange
      source:
        type: Binary
      strategy:
        sourceStrategy:
          from:
            kind: DockerImage
            name: jboss/wildfly:11.0.0.Final
      output:
        to:
          kind: ImageStreamTag
          name: "webapp-image:latest"
      resources:
        limits:
          cpu: 1
          memory: 1Gi

Which I call with:

oc start-build "webapp-build" --from-file=target/ROOT.war

But I get this error on OpenShift Dedicated:

Pulling image "jboss/wildfly:11.0.0.Final" ...
error: build error: image "jboss/wildfly:11.0.0.Final" must specify a user that is numeric and within the range of allowed users

Why is that?

Looks like you are using a non s2i image for a sourceStrategy build. The reason you are getting the error is because the image specifies a non-numeric user.

$ docker inspect docker.io/jboss/wildfly:11.0.0.Final | jq '.[] | .Config.User'
"jboss"

This raises an error in the IsUserAllowed check performed prior to an s2i (sourceStrategy) build starts.

If I am understanding your need correct, you might be looking for the s2i-wildfly image for your build . The jboss/wildfly images are runtime images not intended for s2i use (ie. there are no s2i scripts). So use this sourceStrategy instead:

    sourceStrategy:
      from:
        kind: DockerImage
        # Uses WildFly 11.0
        name: "openshift/wildfly-110-centos7:latest"

Alternatively, if you really want to use that particular image, you can do so by doing the following.

  1. Create a new image with user configured correct and use this from the ImageStreamTag instead of the DockerImage in your build config. oc new-build -D $'FROM docker.io/jboss/wildfly:11.0.0.Final\\nUSER 1001' --to=wildfly:latest .
  2. Specify scripts url parameter in your sourceStrategy configuration. The expectation here is that these scripts know what to do with your binary artifact.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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