eXo Platform in a Docker Container!

eXo Platform Blog

In this article, we will see just how easy it is to execute the eXo Platform in a Docker container, to make your data persist across container restarts and to plug your eXo Platform deployment into a MySQL database.

To be able to test the content of this article, you need to have the following:

  • Docker 1.11 and above (use Docker4Mac or Docker4Windows if you are on one of these two environments, which do not natively support Docker)
  • Docker Compose 1.7 and above
  • Internet access (for downloading Docker images)
  • Coffee (because downloading Docker images can take longer than actually doing a build with Maven 😉 )

First of all, let’s make it simple and start the Community edition of the eXo Platform in a Docker container. For this, we will use the Docker image called exoplatform/exo-community with its default settings (the first run will of course take the longest because it involves downloading the container):

After some time, you will see this message appear in the logs: Server startup in 58220 ms . This indicates that the eXo Platform is initialized and you can start testing your installation by pointing your browser to http://localhost:8080/. exo-started What would happen now if you stop and recreate your container? The answer is your data will disappear because it has been stored directly within the container itself. To overcome this issue, we will use Docker volumes in order to maintain data outside the container. Let’s start by creating two volumes:

And then restart the eXo Platform in a container using these volumes:     

From now on, persistent eXo Platform data (including JCR indexes, Values Storage, etc.) will be stored in the data volume, while logs will go in the logs volume. So you can now stop and delete your container and, when starting a new one, find all of your data available. Is that it? Does this mean I can now move to production since my data can now survive container restarts? Certainly not yet as we still don’t have a database suitable for use in production. In fact, unless configured otherwise, our eXo Platform Docker image uses an HSQLDB database that works great for tests but should not be used in production. We will therefore use MySQL 5.5 as our production database. (Note that the eXo Platform does support other database solutions. See here.) Let’s first start our MySQL server in a Docker container:

 

Now that the database is ready, we can start the eXo Platform while configuring the image so that it uses MySQL. This image, provided by eXo, provides a set of parameters allowing us to adapt the behavior of the image at the time the container is created. (For a detailed list of these parameters, you may refer to this online documentation.)

There it is! A new instance of the eXo Platform now connected to a MySQL database. All your user data will of course survive any recreation of your container. Simply login to your new social intranet, invite other people and start collaborating.

exo-with-content

So you’re running the eXo Platform in production and all is great. But let’s face it: startup is still a tad complicated. To further simplify this, we will use Docker Compose in order to be able to control our complete environment with one simple command.

To that end, let us first stop and delete all previously started containers:

Next, let us create a docker-compose.yml file with the following content:

We can now start our whole setup (i.e., the MySQL database and the eXo Platform) with the following simple command: docker-compose -f ./docker-compose.yml up .

mysql

After this restart with Docker Compose, you will also find no previously created data has been lost.

There are still quite a few things that can be done with the eXo Platform and Docker, so stay tuned to this blog!

In the meantime, the following two links may come in handy for those willing to explore this topic a bit further:

Join The eXo Tribe

Join The eXo Tribe

Register for our Community to Get updates, tutorials, support, and access to the Platform and add-on downloads. Sign in Now!

Related Posts
1 Comment
Leave a Reply

Your email address will not be published.

I have read and accept terms of the privacy Policy. Learn More

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

HTML Snippets Powered By : XYZScripts.com