2

For Openshift: How can I create a docker image based on Wildfly?

This is the Dockerfile is used:

FROM openshift/wildfly-101-centos7
# Install example app on wildfy
COPY target/ROOT.war /opt/wildfly/standalone/deployments/
# Default Startup by Wildfly, so no CMD needed.
# Expose ports we are interested in. Via the run I can use these
EXPOSE 8080 443
# CMD - use the default wildfly start command

After pushing the image, openshift gives the error:

This is an S2I WildFly v10.1.0 Final centos base image responsible for consuming a JEE project and deploying it onto WildFly application server. To use it, install S2I: https://github.com/openshift/source-to-image .

Should I use another image? The jboss/wildfly?

This is what I did to create, tag and push the image.

  • Mvn clean install --- to create the ROOT.war
  • docker build -t project/application .
  • docker tag project/application registry.etc.com
  • docker push registry.etc.com
  • oc new-app mynewapplication

Q2: How can I publish the 8080 port ... or is this done by Openshift?

tm1701
  • 7,307
  • 17
  • 79
  • 168
  • They typically use S2I for this sort of thing but you may be able to do something similar to a pipeline. See https://docs.openshift.com/container-platform/3.7/dev_guide/dev_tutorials/binary_builds.html#binary-builds-pipeline-binary-artifacts. Also, you can use a maven plugin or run docker by hand and then push the resulting image to hub.docker.com and use it for a binary build. So, I think is to take the image you create and push to hub.docker and then do `oc new-build --docker-image=myimage --name=myname` or something like that. – K.Nicholas Jun 02 '18 at 22:12
  • See example of using Wildfly S2I builder with OpenShift in the free eBook OpenShift for Developers at https://www.openshift.com/for-developers/ – Graham Dumpleton Jun 03 '18 at 23:46
  • @Graham Dumpleton - Thank you! S2I is a quick solution. In this case I wanted to use a Dockerfile without S2I. – tm1701 Jun 04 '18 at 18:25
  • @K.Nicholas - Thank you. I tried the FROM wildfly:latest. In my case, I had to prepend it with jboss. – tm1701 Jun 04 '18 at 18:26
  • In case you are not aware S2I is available outside of OpenShift if the issue is you want to build images separately. See https://github.com/openshift/source-to-image – Graham Dumpleton Jun 04 '18 at 22:01

1 Answers1

0

* Q1: S2I is a good way of working when you don't want to think about creating images / containers. The standard Openshift/Wildfly images can be used for S2I.

When you want to work with a docker client with Openshift as a Container As A Service (CAAS) provider you will need another Wildfly image.

This Dockerfile will get you going. You can of course improve it with limiting the user permissions, etc.

FROM jboss/wildfly
COPY target/ROOT.war /opt/jboss/wildfly/standalone/deployments/
# CMD - use the default wildfly default start command

* Q2: Via the Openshift Console you can add a route to explicitly do the port mapping of your ports. Just select via the Console the Applications > Routes. I used the default settings with the 443 secure port.

You should NOT use 8080. In my experience I use Openshift always with a secure 443 port.

CAAS OVERVIEW: For your convenience you can find an overview of the steps for CAAS. Any improvements or further suggestions are very welcom!

tm1701
  • 7,307
  • 17
  • 79
  • 168