How to build a Docker Liferay 7.2 image with the Oracle Database support

How to Build Liferay 7.2 Docker Image with the Oracle Database support
How to Build Liferay 7.2 Docker Image with the Oracle Database support

On June 27th I published the update for Oracle database support for Liferay 7.2 Community Edition. In this article I will show you how to build the Liferay 7.2 Docker image by adding support to the Oracle database. In particular I will explain how to do it using Blade CLI and the Liferay Workspace.

Liferay provides Docker images for

You can pull Liferay’s Docker images from those resources and manage them yourself. Liferay Workspace, however, provides an easy way to integrate Docker development into your existing development workflow with preconfigured Gradle tasks.

This article was born as an extension of the one published by David H Nebinger Building Customized Liferay Docker Images.

The source code of the Liferay Workspace it’s available on this GitHub repository liferay-72-oracledb-docker-images

1. What are the requirements

Before proceeding with the construction of the Docker image, the following requirements must be met.

  1. Installation or upgrade to the latest version of Blade;
  2. Docker Engine 18.x,19.x;
  3. An instance of an Oracle 12c Release 2 database.

For the installation and updating of Blade CLI you could refer to this official Liferay documentation: Installing Blade CLI and Updating Blade CLI. The latest version is You can use this command blade version for checking your version.

Regarding the version of Docker I used both the version 18.09.8 and the 19.03.1. You can check your version with the docker version command. If you do not have an Oracle 12c Release 2 instance ready for use, you might consider using this official Oracle Database 12c Enterprise Edition Docker image. This image is the one I usually use.

2. Create the Liferay Workspace and Dockerfile

First of all we have to worry about creating the Liferay Workspace that we will use in order to configure and build our docker image. Let’s proceed in this way to create the Liferay Workspace.



The first command initializes the Liferay Workspace while the last command using the Gradle createDockerfile task that creates the Dockerfile. The Gradle task execution creates a new directory structure and the Dockerfile. The new directory structure and file created is shown below (command tree -L 3 build).



The created Dockerfile is not good because it contains the reference to the base image of Liferay 7.1. We instead need version 7.2 of Liferay.



In order for the Dockerfile to be created with the correct version of the Liferay image, the following content must be inserted in the file. The specific image has been set on the liferay.workspace.docker.image.liferay property. To find the possible property values you can set, see the official Liferay Portal Docker Hub’s Tags section (e.g., Liferay Portal Docker Tags). In our case we want to get the version 7.2 GA1 of Liferay Portal: liferay/portal:7.2.0-ga1



At this point we re-launch the Gradle createDockerfile task to recreate the new Dockerfile. Now the FROM directive of the Dockerfile contains the correct version of the image.



Before proceeding further, you need to update the version of com.liferay.gradle.plugins.workspace from 2.0.4 to 2.1.3. The change must be made to the settings.gradle file.



3. Docker image configuration

Now all that remains to do is configure our personalized image of Liferay 7.2 so that it is able to connect to an oracle database.

The configs/docker folder is where your configuration and overlay files for your Docker image. You’ll put files here such as your file, your osgi/configs files, overrides for the tomcat-9.0.x files (where x is going to be the version of tomcat included in the bundle), etc.

What do you need for configuring the new image?

  1. JDBC Driver for Oracle Database (download from jdbc-ucp);
  2. Liferay Portal Database All-in-One support (download from Maven Repository);
  3. Configuring the connection to the Oracle database via

The commands shown below do:

  1. The creation of the file whose content is shown below;
  2. The creation of the directory configs/docker/tomcat/lib/ext where the Oracle JDBC driver will be installed;
  3. The creation of the directory configs/docker/tomcat/webapps/ROOT/WEB-INF/lib where the Liferay driver will be installed for Oracle database support;
  4. The copy of the driver liferay-portal-database-all-in-one-support in configs/docker/tomcat/webapps/ROOT/WEB-INF/lib.



The file you see, configuring the JDBC connection to the Oracle database also enables access to the GogoShell.


  At this point we re-launch the Gradle createDockerfile task, but specify the environment using the parameter -Pliferay.workspace.environment=docker (blade gw clean createDockerfile -Pliferay.workspace.environment=docker). This time the contents of the build/docker directory will also contain our configurations.  


Note that this step (the execution of the Gradle task createDockerfile) is not typically needed. I’m just using this command so I can see what will be used for the Docker image without actually creating the image yet.


4. Build and run the Docker image

At this point we can proceed with the build of our Docker Liferay 7.2 image with support for the Oracle database. The Gradle buildDockerImage task does just that.



The figure below shows the output of the Gradle task execution, while the following figure shows the details of the image just created.


Figure 1 - Output of the gradle buildDockerImage task

Figure 1 – Output of the gradle buildDockerImage task


As you can see from figure 2, the docker environment is used as a tag of our image (liferay-72-oracledb-docker-images:docker).


Figure 2 - Output of the command docker image ls

Figure 2 – Output of the command docker image ls


All that remains is to start our image and we can do it with the command to follow. The docker command makes sure to expose ports 8080 (web) and 11311 (Gogo Shell). It also makes sure to use the volume to allow us to easily deploy our applications, just copy the bundles into the $(pwd)/build/docker/deploy directory.



To view the Liferay logs you need to run the command docker logs -f Liferay72-Oracle. The Docker command to access the machine is shown on the log.


Figure 3 - Output of the Liferay log file

Figure 3 – Output of the Liferay log file


You can monitor the status of our container using the docker ps command. Figure 4 shows the status and which TCP / IP ports are exposed.


Figure 4 - Output of the command docker ps

Figure 4 – Output of the command docker ps


Figure 5 shows the Oracle schema populated with Liferay tables at start-up.

Figure 5 - Get Liferay portal version from RELEASE_ table

Figure 5 – Get Liferay portal version from RELEASE_ table


Docker has become increasingly popular in today’s development lifecycle, by providing an automated way to package software and its dependencies into a standardized unit that can be shared cross-platform.

You can now manage Liferay’s Docker images in Liferay Workspace and push your Docker custom image on Docker Hub or other registry 😉 !

Antonio Musarra

I began my journey into the world of computing from an Olivetti M24 PC ( bought by my father for his work. Day after day, quickly taking control until … Now doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB, TIBCO, PHP.

You may also like...

Liferay 7.2 GA2 & Wildfly 16Come installare Liferay 7.2 GA2 su Wildfly 16 + il supporto Oracle Database 19c

Nel corso di questo video tutorial, vedremo come installare Liferay Portal 7.2 GA2 Community Edition su WildFly 16 con il supporto verso Oracle Database 19c.

Il supporto per WildFly 16 è stato aggiunto da Liferay 7.1 (vedi Matrice di Compatibilità). Il supporto per Oracle Database 19c è disponibile dalla versione 7.0 di Liferay. Il repository GitHub liferay-portal-72-wildfly-16 ( contiene il layout d'installazione e i file di configurazione di Liferay e WildFly.

Nel caso in cui non abbiate un'istanza Oracle Database 19c disponibile, potreste creare la vostra da zero, per questo v'invito a leggere l'articolo How to setup Docker container Oracle Database 19c for Liferay Development Environment. Sul mio account SlideShare sono disponibili le slide in formato PDF Non esitate a lasciare i vostri feedback su questo video tutorial.

Cos'è il progetto CIE/CNS Apache Docker - Developers Italia

In questo video introdurrò il progetto CIE/CNS Apache Docker di Developers Italia ( nato circa due anni fa.

L'obiettivo di questo progetto è quello di fornire un template pronto all'uso che realizza un sistema di autenticazione tramite la Smart Card TS-CNS (o CNS) e la CIE (Carta d'Identità Elettronica) basato su Apache HTTP. Ognuno può poi modificare o specializzare questo progetto sulla base delle proprie esigenze Si tratta di un progetto docker per la creazione di un container che implementa un sistema di mutua autenticazione o autenticazione bilaterale SSL/TLS.

Questo meccanismo di autenticazione richiede anche il certificato digitale da parte del client, certificato che in questo caso risiede all'interno della TS-CNS o della CIE. La particolarità del sistema implementato (attraverso questo container) è quella di consentire l'autenticazione tramite:

  • La TS-CNS (Tessera Sanitaria - Carta Nazionale Servizi), rilasciata dalla regione di appartenenza;
  • La CIE (Carta d'Identità Elettronica), rilasciata dal comune di residenza.

Nella versione 2.0.0 il progetto è stato aggiornato per essere uniforme alle linee guida di Bootstrap Italia. A seguire alcune risorse che possono essere utili.

  • Cos’è il progetto CIE/CNS Apache Docker (
  • CIE Carta d'Identità Elettronica (
  • Carta Nazionale dei Servizi (
  • Raspberry Pi – Un esempio di applicazione della TS-CNS (
  • Pubblicare il servizio CIE/CNS Apache Docker su Azure Cloud (
  • Come accedere al portale VETINFO tramite TS-CNS e Mac OS (