Providing Files to the Container¶
The Liferay container uses the files you provide to execute the following use cases:
Configure Liferay with
Deploy apps and other artifacts
Update the Patching Tool
All of the use cases can be triggered on container creation when the container finds files in specific folders within key container folders.
Key Container Folders:
The Container Lifecycle and API specifies the scanned subfolders, the phases in which the container scans them, and the actions taken on their files.
You can provide files to the container in several ways.
Ways to Provide Files:
All of the use cases, except for deploying artifacts and using
.config files, require making files available on container creation. Bind mounts and volumes accomplish this. Deploying artifacts and applying
.config files can be accomplished on container creation using bind mounts and volumes, or at run time using
Bind mounts are used in the examples here as they are simpler than volumes for providing files. As you prepare files for mounting to a container, it’s helpful to organize them in a way that’s easiest for you to manage. Bind mounting to Liferay containers, organizing files, and using
docker cp are covered here.
Bind Mount Format¶
You can specify any number of bind mounts to a
docker run command. Each bind mount follows this format:
-v [source path in host]:[destination path in container]
The bind mount source can be any folder path or file path in the host. The bind mount destination can be any folder path or file path in the container.
Scanned Container Folders¶
The container scans these folders.
/mnt/liferay/files(all files and subfolders are scanned)
Please see the API for the actions and use cases associated with each folder.
Organizing Files for Bind Mounting¶
You can organize Liferay container bind mounts in several different ways:
Bind to one or both of the key folders:
Bind to their subfolders
Bind to a mix of subfolders and files
The table below shows some example bind mount methods and describes their pros and cons.
Example Bind Mounts¶
Centralizes the input files.
Input files must be organized in subfolders that the container expects (see the locations listed above).
Flexibility to use input file groups in different locations on the host.
More host file locations to manage.
Mount to individual files
Input files are clearly visible in the
Lengthy docker run commands. Even more host file locations to manage.
The most general way to provide files to the container’s configuration phase is to bind mount a host folder to the container’s
Bind Mounting a Host Folder to
If you want to centralize files for configuring, patching, and deploying to Liferay, consider bind mounting a host folder to the container’s
Most of the examples in the use case articles use this bind mount strategy.
Hre are the steps:
Designate a folder on your host to serve as a base folder.
In the base host folder, create subfolders that correspond to all of the
/mnt/liferaysubfolders that the container acts on. Please see Container Lifecycle and API for container folder details.
cd [host folder] mkdir deploy files patching scripts
[host folder] ├───deploy ├───files ├───patching └───scripts
You don’t have to create all of the subfolders, just the ones you’re populating.
Populate the subfolders with files for the container to act on.
[host folder] ├───deploy ├───files/portal-ext.properties ├───patching/[Security Fix Pack file name].zip └───scripts
docker runcommand, bind mount your base host folder to the container’s
docker run -v [host folder path]:/mnt/liferay ...
Per the Container Lifecycle, your new container acts on the files in (and nested under) your mounted host folder and then starts Tomcat
docker cp command is a convenient alternative for deploying applications, modules, and configurations to a Docker container.
docker cp [file] [container]:[folder path]
Deploying an application:
docker cp some_app.lpkg my_container:/opt/liferay/deploy
Deploying a configuration file:
docker cp com.liferay.journal.configuration.JournalServiceConfiguration.config my_container:/opt/liferay/osgi/configs
If you use
docker cp on macOS, however, the file’s ownership is preserved, instead of changing to user/group
liferay. Here are a couple workarounds:
Set the file ownership and permissions using
taras input to the
docker cpcommand. Here’s an example:
tar -cf - command.sh --mode u=+rwx,g=-wx,o=-wx --owner liferay --group liferay | docker cp - my_container:/usr/local/liferay/scripts/pre-startup
Open a Bash session in the container after using
docker cpand change the file’s ownership.
docker exec -it my_container bash
chown -R liferay:liferay /usr/local/liferay/scripts/pre-startup/command.sh
Now you know how to provide files to the container using bind mounts and
docker cp commands. Please see the Container Lifecycle and API for more details. For use case details, please see these articles: