You must create the Docker container, and push it to a registry, where it is referenced
by IBM Cloud Private.
About this task
Use the official WebSphere® Application Server for Developers Liberty image in Docker Hub.
Multiple images are available in this repository. The image with the tag beta
contains the contents of the installation archive for the monthly beta. The other images are all
based on the most recent generally available fix pack.
The
kernel image contains just the
Liberty kernel and no additional runtime
features. You can use this image or custom-built images that contain only the features that are
required for a specific application. For example, the following Dockerfile example snippet starts
with this image, copies in the
server.xml file that lists the features that are
required by the application, and then uses the
installUtility command to download
those features from the online
repository:
FROM websphere-liberty:kernel
COPY server.xml /config/
RUN installUtility install --acceptLicense defaultServer
The webProfile6 image contains the features that are required for Java EE6 Web
Profile compliance. It also pulls in more features to align the contents with the features that are
available for download by using the runtime JAR file, most notably the features required for OSGi
applications.
The webProfile7 image contains the features that are required for Java EE7 Web
Profile compliance. The javaee7 image extends this image and adds the features that
are required for Java EE7 Full Platform compliance. The javaee7 image is also
tagged with latest.
The
webProfile6,
webProfile7, and
javaee7
images also all contain a common set of features that are used for a typical production scenario.
The following features make up this common set of features:
- appSecurity-2.0
- collectiveMember-1.0
- localConnector-1.0
- ldapRegistry-3.0
- monitor-1.0
- requestTiming-1.0
- restConnector-1.0
- sessionDatabase-1.0
- Update the server.xml file to accept HTTP connections from outside of the
container by adding the following element inside the server stanza:
<httpEndpoint host="*" httpPort="9080" httpsPort="-1"/>
- Create an Eclipse project, such as sample-one-container. In this project
include, the Dockerfile and the WAR file from the server.xml file. See the following Dockerfile
example:
FROM library/websphere-liberty:webProfile7
Add sample-one.war /opt/ibm/wlp/usr/servers/defaultServer/apps
COPY server.xml /opt/ibm/wlp/usr/servers/defaultServer/
ENV LICENSE accept
In this Dockerfile, the Liberty image is
customized by copying the WAR file into the drop-ins directory, which installs
the application and starts the server. The server.xml is replaced with the
modified server.xml to allow HTTP connections from the outside of the
container. The license is also accepted.
- Gather the server.xml and WAR files together in this project, and prepare
to run docker build to create a Docker image.
- Open a command line, and set the current directory to the sample-one-container project
directory, and run the Docker build. This is a custom Docker build, which starts with the Liberty Docker hub image and adds an application
and corresponding server.xml configuration. See the following example, which
displays the running of a successful
build:
arthurs-mbp:docker-hub arthur$ docker build .
Sending build context to Docker daemon 957.4kB
Step 1/4 : FROM websphere-liberty:kernel
---> 3fd79ff460ff
Step 2/4 : COPY server.xml /config/
---> Using cache
---> a0e43965425f
Step 3/4 : COPY airlines.war /config/apps/
---> Using cache
---> dfc6aee86df5
Step 4/4 : RUN installUtility install --acceptLicense defaultServer
---> Using cache
---> d5ab21decab4
Successfully built d5ab21decab4
arthurs-mbp:docker-hub arthur$
- Log in with your Docker user ID and password. When you log on to Docker Hub, output similar to the following example is displayed:
arthurs-mbp:docker-hub arthur$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: arthurdm
Password:
Login Succeeded
arthurs-mbp:docker-hub arthur$
- After the build finishes, create the tag for the image. This tag represents the name by which this image is referenced in the registry. See the
following
example:
arthurs-mbp:docker-hub arthur$ docker tag d5ab21decab4 arthurdm/websphere-liberty
- Push the image into the Docker Hub repository, making it public so that it can be downloaded
and run. See the following example:
arthurs-mbp:docker-hub arthur$ docker push arthurdm/websphere-liberty
The push refers to a repository [docker.io/arthurdm/websphere-liberty]
c2eefa54fcc7: Layer already exists
09fa033b42e3: Layer already exists
753266ce94a2: Layer already exists
0a76debd7d35: Layer already exists
d86dd55017f1: Layer already exists
d5e2acba7cce: Layer already exists
eefb3f013a83: Layer already exists
28fca5e92849: Layer already exists
3e60706b7714: Layer already exists
1a39a1088d6e: Layer already exists
73e5d2de6e3e: Layer already exists
08f405d988e4: Layer already exists
511ddc11cf68: Layer already exists
a1a54d352248: Layer already exists
9d3227c1793b: Layer already exists
latest: digest: sha256:9e41f2a269360fbd0ff926434ab4df38cce49aa83442b1a38eaf13049cb164b2 size: 3453
arthurs-mbp:docker-hub arthur$
What to do next
After you push the application to the repository, install the application in your IBM Cloud Private environment, by specifying the image,
arthurdm/websphere-liberty. This installation is accomplished through the Helm
chart.