CLOUD PAAS / CONTAINERS

Building Custom Container

This guide has been reviewed and reformatted for Ruk-Com Cloud PaaS. Screens may vary slightly by platform version.

Click or tap a screenshot to view it at its original size.

Objective

This guide explains how to use Building Custom Container on Ruk-Com Cloud PaaS, with ordered procedures and practical verification points.

Before you begin

  • Sign in with an account permitted to manage the relevant environment.
  • Confirm the target environment, region and resources before saving changes.
  • Create a backup or rollback plan before changing a production system.

Provisioning your Docker image is made easier with Ruk-Com Cloud. It builds on a pre-existing foundation (i.e. - the CentOS 7 base template), making it possible to skip all the steps completed within the "parent" template and add only the modifications you need. We'll also take a look at the steps to prepare a custom WildFly image - a flexible, lightweight Java application server that is a direct successor to JBoss.

Ruk-Com Cloud PaaS procedure screenshot

The most common way to create a Docker image is to write a special Dockerfile that adds automation through listing the required commands into a simple text file that is then read and executed by the Docker daemon.
This way new templates will be created automatically according to the instructions (otherwise you will have to manually run all the required actions one by one).

Below we will explain all the specifics of custom images running on our platform. And as a result, you get a docked version of WildFly server ready to use right inside the platform.

So let's take a step-by-step look at the necessary operations:

Composing Dockerfile

Start by creating an empty file - declare all appropriate actions directly in it and proceed with the following instructions.

Note: This section explores the essential features and basics of your Dockerfile. However, if you want to dive deeper into the implementation specs and get more details/instructions, You can find references on their website.dockerfilethat can be official

You can also download a pre-prepared dockerfile. (With the example WildFly image) The next section explains how to manually create the file.

1. The first step is to specify a basic template for creating the image. We will use jelasticdocker/jelastic-centos7. with operating systemCentOS 7that has already been configured internally Settings within the dockerfile should be done using the commandFROM:

FROM jelasticdocker/jelastic-centos7-base:latest

2. The second step allows you to specify general image information (such as metadata or variables) which will be required during further configuration. You can see the example below to set the necessary settings:

LABEL maintainer="RukComCloud,Inc"
ENV WILDFLY_VERSION 13.0.0.Final

ENV ADMIN_USER rukcomcloud

ENV ADMIN_PASSWORD rukcomcloud

where:

  • LABEL - Allows you to set image metadata via appropriate key-value pairs (e.g. Docker image creator, version).
  • ENV - Set main environment variables, e.g.
  • WILDFLY_VERSION - WildFly version to be created; Can be changed to another version if necessary(current version listavailable and can be used)
  • ADMIN_USER - Administrator name for later access to the WildFly control panel.
  • ADMIN_PASSWORD - Specify the desired password.

3. Now you can declare the required configuration using shell command - useRUNto be processed for this purpose
First, you need to install the Java Development Kit (in our case, OpenJDK version 8) and important documentation.tar(Used to expand downloaded file information)

RUN yum -y install java-1.8.0-openjdk-devel tar && yum -y update;

This command ends by triggering general updates of installed packages.

4. Next is the announcement of additional actions for downloading the WildFly source code from the official website and extracting it to the /opt folder.

RUN cd /opt && curl -O https://download.jboss.org/wildfly/${WILDFLY_VERSION}/wildfly-${WILDFLY_VERSION}.tar.gz \
&& $(which tar) xf wildfly-${WILDFLY_VERSION}.tar.gz \
&& rm wildfly-${WILDFLY_VERSION}.tar.gz

5. The fifth step requires you to create a symlink to shorten the path to WildFly's main directory and make it more accessible.

RUN ln -s /opt/wildfly-$WILDFLY_VERSION /opt/wildfly

6. Then proceed to create the main configuration file for the WildFly server and put in all the required options.

RUN echo -en "JAVA_HOME=\"/usr/lib/jvm/java\""'\n'\
"JBOSS_HOME=\"/opt/wildfly\""'\n'\
"JBOSS_USER=wildfly"'\n'\
"JBOSS_MODE=standalone"'\n'\
"JBOSS_CONFIG=standalone.xml"'\n'\
"STARTUP_WAIT=60"'\n'\
"SHUTDOWN_WAIT=60"'\n'\
"JBOSS_CONSOLE_LOG=\"/var/log/wildfly/console.log\""'\n'\
"JBOSS_OPTS=\"-b 0.0.0.0 -bmanagement=0.0.0.0 -Djboss.management.http.port=4949 -Djboss.management.https.port=4848\"" >> /etc/default/wildfly

7. CentOS 7 starts up using the default Systemd script, but WildFly Server requires the more traditional default SystemV. So you need to copy the default initscript to the /etc/init.d folder and edit the appropriate configuration to avoid systemd redirects.

RUN wget https://raw.githubusercontent.com/wildfly/wildfly-core/master/core-feature-pack/src/main/resources/content/docs/contrib/scripts/init.d/wildfly-init-redhat.sh -O /etc/rc.d/init.d/wildfly;
sed -i "/# Source function library/a\SYSTEMCTL_SKIP_REDIRECT=1" /etc/init.d/wildfly; chmod +x /etc/init.d/wildfly;

8. Next we specify WildFly to run when the container is started. By adding relevant system users and changing file ownership rights.

RUN chkconfig --add wildfly; chkconfig wildfly on; mkdir -p /var/log/wildfly; adduser wildfly;
chown -R wildfly:wildfly /opt/wildfly-$WILDFLY_VERSION /opt/wildfly /var/log/wildfly;

9. In addition to that, you can add user credentials. We have set up the first step for accessing the server admin panel.

RUN /opt/wildfly/bin/add-user.sh --user $ADMIN_USER --password $ADMIN_PASSWORD --silent --enable

10. Now we can correctly link to the admin panel at index.html page by setting the corresponding redirect (i.e. in this case our image will be deployed to the container without attaching external IP port 4949 and HTTP connection).

RUN sed -i "s/<a href=\"\/console\">/<a href=\"\/console\" onclick=\"javascript:event.target.port=4949;event.target.protocol=\'http:\';\">/" /opt/wildfly/welcome-content/index.html

11. Add theSet localeEnglish into the container

RUN localedef -i en_US -f UTF-8 en_US.UTF-8

12. Another necessary action is to set our Docker image to listen on required ports while running using the commandEXPOSE

EXPOSE 22 80 443 8080 8743 9990 9993 8009 4848 4949

13. The last step you need to set.ENTRYPOINTTo make the container run as executable In our case we should specify bash shell.

ENTRYPOINT ["/bin/bash"]

And this is all Be sure to save all declared settings to get a ready-to-use dockerfile.

Adding Image to Repository

Once the appropriate dockerfile is prepared, you are ready to build the respective WildFly image and push it to storage.

Note:Before starting, you need to make sure that you have the appropriate version of Docker CE installed. (according to the type ofOperating systemused) to perform the installation command for the currently used machine as described below.

So follow these steps:

  1. Run commanddocker buildWith the necessary parameters to create a new image on your machine:
sudo docker build -t {image_name} {dockerfile_location}

where:

  • {image_name}- name where the image is stored; Or you can add the version tag after the ":" separator (e.g. Ruk-Com/wildfly:latest).
  • {dockerfile_location}- local path or URL to your dockerfile (can be set to "." if the file is in the current directory)

2. You will receive a message upon successful creation with a new image ID to certify that your workstation is ready and you can view a list of all local templates with the command:

sudo docker images

3. At the end you need to push (upload) your image to the registry with the corresponding command:

sudo docker push {image_name}

Here it should be specified{image_name}The same name that you specified during image creation step 1.

You will be requestedrequestFurther to verify that you are the account owner. (by specifying username password and associated email address) to complete this operation.

Tips:You can log in to the registry in advance using the docker login command (so your personal data will be stored in the docker login file).~ /.docker/config.jsonat the home directory on your machine

Deploying Image at Ruk-Com Cloud

Once your images are successfully stored, they are available on the Ruk-Com Cloud platform and can be added to specific environments on the Docker board, integrated into the component.topology wizarddashboard

Click the New Environment button at the top of the dashboard, select the Docker tab within the open environment wizard, and click Select Image.

1. You can use the Search tab to search for additional images in Docker Hub or return to the previous section to customize them. It can be used with any image type (including private) and stores your templates for easier access.

Ruk-Com Cloud PaaS procedure screenshot

Once clicked, select the required environment layer on the left. (In our case, choose Application Servers) then click the buttonAdd New Image

2. Add a new image by specifying a name in the field.Namesuch as

{registry_hostname}(You can jump to the official Hub Registry)/{account}/{image_name}
Additionally, specifying private storageprivate repositoryAppropriate username and password credentials should be provided.

Ruk-Com Cloud PaaS procedure screenshot

We use Docker Hub's public repository, which is within the central Registry Hub, so only the repository name is used and clicked.Add

3. After that, the image you added will appear in your list. Just click once to add it to the topology. Additionally, this template will remain recognized and displayed on the page, where it can be easily found during container selection. (If you want to remove can click the trash can icon button to delete)

Ruk-Com Cloud PaaS procedure screenshot

Manually set up the rest of the required configuration and create the environment (you can read the details here).ConfigurationMore in the manual) then clickCreate

4. When your environment with the appropriate internal image appears on the dashboard, you can access it by clicking the button.Open in Browser

Ruk-Com Cloud PaaS procedure screenshot

Note:In case you have not selected a template into your App Server or Balancing environment, you will need to use the button with the same name next to the container to open it.

So, when opening the browser, you will see the WildFly start page, which means that everything is configured correctly and the newly created container is fully functional.

Ruk-Com Cloud PaaS procedure screenshot