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. Read Docker’s extensive documentation to learn more.
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.
In this tutorial, you’ll learn how to do the following tasks within a workspace:
- Creating a Docker container based on a provided Liferay DXP image
- Configuring the container
- Interacting with the container
- Building a custom Liferay DXP image
Choose the Docker image you need. This is configured in your workspace’s
gradle.propertiesfile by customizing this property:
To find the possible property values you can set, see the official Liferay DXP Docker Hub’s Tags section (e.g., Liferay Portal Docker Tags. For example, if you want to base your container on the Liferay Portal 7.1 GA2 image, you would set this property:
Run the following command from your workspace’s root folder:
This command creates a new container named
[projectName]-liferayapp. A new
build/docker folder is generated in your workspace. This folder is mounted
into the container’s file system. This means files in workspace’s
folder are also available in the container’s
Any projects in your workspace are automatically compiled and copied to the
build/docker/deploy folder when the container is created; this means that when
the container is started, all your projects are deployed to the container. All
configurations are also applied to the container. You’ll learn more about
configuring your container next.
Before starting your container, you may want to add additional portal configurations. This could include things like
- Property overrides (e.g.,
- Marketplace app overrides
- App server configurations
- License files
You can do this by applying files (and their accompanying folder structures, if
necessary) to your workspace’s
configs/docker folder. This folder is treated
as your Liferay Home for Docker development; you add additional files that
overlay your workspace’s
configs/common folder and your Liferay DXP container’s
For example, to enable the Gogo shell for your container, add
configs/docker/portal-ext.properties file to your workspace with the
This lets you access your container using Gogo shell via telnet session.
Once the container is started, the configurations stored in
configs/docker are transferred to the
build/docker/files folder, which
applies all configurations to the container’s file system. For more information
configs folder, see
Next, you’ll explore the commands for interacting with the container.
startDockerContainer: starts the container.
logsDockerContainer: prints the portal runtime’s logs. You can exit log
tracking mode while maintaining a running container (e.g., [Ctrl|Command] +
dockerDeploy: deploys the project to the container’s
deploy folder by
copying the project archive file to workspace’s
This command can also be executed from workspace’s root folder to deploy all
projects and copy all Docker configurations (i.e., from the
configs/docker folders) to the container.
stopDockerContainer: stops the container.
removeDockerContainer: removes the container from Docker’s system.
Next, you’ll learn how to build a custom image.
You can preserve your container’s configuration by building it as an image. To build your custom Liferay DXP image, run
Dockerfile is generated for your container when building your image. To do
this manually, run
Dockerfile is generated in your workspace’s
build/docker folder. For
more information on how to configure the
Dockerfile, see Docker’s
Dockerfile reference documentation.
Your custom image is now available! Run
docker image ls to verify its
You can now manage Liferay’s Docker images in Liferay Workspace!