Docker Community Forums

Share and learn in the Docker community.

How to push or commit an enriched application?

(Richarduijen) #1


I’m still new at using docker, so if this topic is discussed or explained somewhere (else), please point me there.

I’m trying to build a liferay website with plugins in a docker container. So far so good, I managed to have liferay running in docker on a postgresql database. Now, I am struggling with the plugins.

If I copy the plugin.lpkg file to the automatic deploy directory in the Dockerfile, the file is not copied when I run the container. So the plugin must be installed manually after the container has started, if I use this way to develop the website.

Another idea I had, was to have a container running, then manually install the plugin (by copying it to the deploy directory, after which it is running in the container). Then commit the - I thought: changed - container. And push it to the repository. (The push process cost me all morning - soooooo slow that I am also thinking about reconsidering the use of docker altogether.)

After a successful push, I ran the image on a different computer… but the plugin was not there.

I don’t exactly know what steps liferay portal takes to deploy lpkg files. Therefore I’m running out of ideas on how to develop the portal container further. Any ideas? Has anyone else ventured into these areas? Is there a third way to collect the container contents (not being user data) to the repository (apart from building from dockerfiles, or the committing of changed containers)?

Or did I simply make an error when I committed the changed container or pushed the committed image?

(Jeff Anderson) #2

Can you share the Dockerfile or image that you are using to run this application? Much of this behavior will depend on how exactly that image works.

(Richarduijen) #3

Ok, here goes:

I create a postgresql database:

sudo docker run --name lep-postgresql -v /opt/pg_lr/dbdata:/var/lib/postgresql -d postgres:9.4

Followed by:

sudo docker run -it --link lep-postgresql:postgres --rm postgres:9.4 sh -c 'exec psql -h $POSTGRES_PORT_5432_TCP_ADDR -p 5432 -U postgres'

CREATE USER lportal WITH PASSWORD 'lportal';

Then I launch the Liferay with Tomcat container:

sudo docker run --name=lr -p 8080:8080 -v /var/liferay-home/deploy:/opt/liferay-portal-6.2-ce-ga4/deploy --link lep-postgresql:db_lep -d -e DB_TYPE=POSTGRESQL richarduijen/liferay_so_lrsync:latest

The liferay_so_lrsync container is built with the following dockerfile content:

# Liferay + Social Office + Liferay Sync + RCS Newsletter
# 0.1 (20150901): working version with persistent postgresql database without plugins
# 0.2 (20150902): (not yet) working version with the above and Social Office CE plugged in
# Based on Liferay 6.2 VERSION 0.0.7 using liferay 6.2-ce-ga4 by Samuel Nasello <> 
# Reason: I could'nt find any versions supporting persistent data (including pages) or liferay plug-ins. Furthermore, I wanted this particular configuration as a template. 

# Standard context of debian and Java 7 #

FROM snasello/docker-debian-java7:7u79

MAINTAINER Richard Uijen <> 

# Basic Liferay install with Tomcat #

# install liferay 
RUN curl -O -s -k -L -C - \
	&& unzip -d /opt \
	&& rm

# Add database and plugin specific settings #

# add config for databases 
RUN /bin/echo -e '\nCATALINA_OPTS="$CATALINA_OPTS -Dexternal-properties=portal-bd-${DB_TYPE}.properties"' >> /opt/liferay-portal-6.2-ce-ga4/tomcat-7.0.42/bin/

# add configuration liferay file (content extended for RCS newsletter and Social Office)
COPY lrsols/        /opt/liferay-portal-6.2-ce-ga4/
COPY lrsols/      /opt/liferay-portal-6.2-ce-ga4/
COPY lrsols/ /opt/liferay-portal-6.2-ce-ga4/

# Social Office plugin (abandoned in version 0.2)   #
# adapted conformingly     #

# add the plugin to the deploy directory for automatic deployment of Social Office CE plugin at startup (currently impossible to download directly from
#COPY so/SocialOfficeCE.lpkg                 /var/liferay-home/deploy/SocialOfficeCE.lpkg

# Liferay sync plugin (to be added in version 0.3) #

# RCS Newsletter plugin (to be added in version 0.4) #

# volumes (unknown what var liferay home is supposed to do, the other is the liferay home directory)
VOLUME ["/var/liferay-home", "/opt/liferay-portal-6.2-ce-ga4/"]

# Ports 
EXPOSE 8080 

ENV JAVA_HOME /opt/java 

CMD ["run"]
ENTRYPOINT ["/opt/liferay-portal-6.2-ce-ga4/tomcat-7.0.42/bin/"]

I have tried to copy the plugin file to the autodeploy folder in the dockerfile, but apparently that is not the way the dockerfile works… the file didn’t show up in the folder, no error message was given after running the image.

I then manually put the plugin file in the /var/liferay-home/deploy folder and I could see how it was processed. After logging into the liferay application, I could see the Social Office bar.

I committed the running container, and ran it with the same command as above (adapted for the right image), no Social Office. I saved the image, and ran it on a different machine: no Social Office.
The only way forward that I see now, is to copy the liferay processes used for the autodeploy function, but that is a lot of work!

I am wondering what changes the commit function does and what it doesn’t capture. I’m running version 1.8.1 of Docker. I want to run it on a diskstation, with Docker 1.6 on it.

(Jeff Anderson) #4

Ah, I see what is happening. You are putting the plugin in the volume, which isn’t actually part of the image.

The short definition of a volume is a bind-mount into the container. The files in a volume are stored outside the container’s layered filesystem. Committing a container will only commit files in its filesystem.

You can use the docker diff command to see what files have changed on a container’s filesystem before committing it to a new image.

There are a couple options:

  • You could manually create the data in the volume on the second system and then start the container. (not ideal for repeatability)
  • At startup, you could have your container check for the presence of the needed plugins and copy them to the volume if they don’t exist.

Hopefully this helps


(Richarduijen) #5

I read your words, I get a picture of what they could mean, it makes sense to me, but I’m not sure that I understood what you wanted to convey to me. I will try to translate in my words what I think I understood and my conclusions…

I copy and paste a plugin file into a directory in Ubuntu, which is mount-bound to a location in the container, which triggers liferay to import the plugin into its system (creating folders, changing settings, making references, indexes, and so on). But this is not stored within its file system (?).

What I understand now, is that by doing this, liferay creates artefacts that are stored outside its file system (where?). (The diff folder in var/lib/docker/ contained three new items, two of which showed up in the output of the docker diff command. Those were binary files that contained references to one of the imported portlets (I did a grep search).)

first option: I think this is a no-go, since I have to add data to folders that are not empty. I read that when data is present in a folder at startup of a container, the data in the container will not be put there, but the data in the container is used. I don’t know whether this is limited to files/folders with identical names.

Second option extends the process of building up the application beyond the dockerized container building process. This is what I did in my other Docker project, in which I setup Odoo 8 to work on my Diskstation. In that case, I did not conceive the installation of the components as part of building the docker image.

So, I will look at the port, settings and volume requirements for operating, backing up and restoring the application and to the security aspects before finalising the build.


(Richarduijen) #6

I am starting to understand the file system references, after reading this blog about volumes.

(Richarduijen) #7

Done! I have put my work in a public repository now: richarduijen/liferay_so_lrsync.

(Sjaligam) #8


We have a application that completely runs on liferay and its a very common application for all our schools. ->whenever liferay new release comes into the market, we try to install the whole bundle on our DEV, then modified accordingly and use that tar to deploy on QA/UAT/PROD, but we again change few things like ports, schemas in the conf files in tomcat folders as per environment. So, we are really facing difficulty with this as we do this whole stuff manually. So, i want help in 2 things a)i want to do the deployments fast, easy and accurate. b)if a new release of liferay come to the market, the upgrade deployment or creating the environment should be fast,easy and accurate.

I want to do this with docker, could you please give me the step by step proceedure t do it.

we work on RHEL boxes.