Docker Examplesdocumentation for the dotCMS Content Management System

Introduction

This document is not intended to be a Docker primer. There are plenty of sites that provide this type of documentation for Docker. The purpose of this document is to give specific examples of how dotCMS can be run with Docker. Think of it as a “dotCMS in Docker” primer for dotCMS developers, system administrators, and devOp engineers.

Examples

Simple Demo Example From Command Line

We are going to start with this simple example of running dotCMS in Docker from the command line. This will run the Demo/Starter site and will be very similar to extracting dotCMS from one of the compressed release files. It will use the default H2 database and create the Demo/Starter data when it starts up.

Warning - Because of the default isolation of containers, the dotCMS data you create in this instance will not persist after you shutdown dotCMS. We will show how options can be added to persist the data but this initial example will not persist data. You have been warned.

The simplist way to run dotCMS in Docker is:

docker run -itp 8080:8080 dotcms/dotcms:latest

This command runs dotCMS in docker and after dotCMS finishes initializing, you can access dotCMS on port 8080. This is running with H2 as its database. It is also running without a license so enterprise functionality is not available.

NOTE - When done, you can just use <Ctrl-C> to stop the dotCMS container

Running with dotCMS license file:

docker run -itp 8080:8080 -v ${PWD}/license.dat:/data/local/dotsecure/license/license.dat  dotcms/dotcms:latest

Of course, ${PWD} just expands to the directory you are running the command from. You can replace this with a different path if your license file is in a different location. Please note: this must be a fully qualified path - no relative paths permitted here.

Running with dotCMS license pack:

docker run -itp 8080:8080 -v ${PWD}/license.zip:/data/shared/assets/license.zip dotcms/dotcms:latest

Of course, ${PWD} just expands to the directory you are running the command from. You can replace this with a different path if your license pack is in a different location. Please note: this must be a fully qualified path - no relative paths permitted here.

Full Container Stack on Single Node

If you are looking for a way to run all dotCMS containers locally on a single machine, this method is for you. This method is particularly helpful for testing and debugging. Even if you want to setup a standard demo but want to use a DB other than the default H2 database, this is probably the method you want.

In directory with this docker-compose.yml. file, run this command:

docker-compose up

dotCMS is now available on port 80 of your Docker host. - e.g. http://localhost/ It is important to note that this option runs multiple Docker containers as indicated in the docker-compose.yml file. Of course this file can be modified as needed, but the default implementation runs haproxy for a loadbalancer, external hazelcast for caching, hazelcast-mancenter for monitoring caching, two different ElasticSearch containers, a dotCMS container, and a seperate PostgreSQL container for the database engine.

This option uses named volumes in the same way that the previous Docker run persistent data examples did. Data is persisted using named volumes. Once the container is stopped the data from the assets, DB, and ES indexes will be persisted until you remove the docker volumes.

When ready to shutdown the dotCMS containers, you can use <Ctrl-C>. Then you need to run:

docker-compose down

After the containers are stopped, if you want to get rid of the persisted data, you will need to run the relevant container and volume prune commands. If you do not remove this data, it will be used next time you run docker-compose up with the same docker-compose.yml file or whenever those volume names are used by another deployment (config file or command line options).

dotCMS Cluster with Full Container Stack on Single Node

To run a dotCMS cluster on a single node, you can use a full blown orchestrator like Swarm, Kubernetes, etc or you can use docker-compose. To keep things simple here, we are going to use docker-compose and assume that you have already run your docker-compose up command and dotCMS and the other related containers are already running on your system.

Once you have one dotCMS container and its dependent containers running, you can easily add additional instances of containers like dotCMS. For dotCMS clustering to work, you must have enterprise licenses installed - you must have at least as many licenses loaded in the system as the number of dotCMS containers you plan to run. You can install these licenses by either mapped a valid enterprise license pack by uncommenting the the license.zip line in the docker-compose file, or by uploading the license.zip file in the backend on the System->Configuration->Licensing tab.

Once you have at least on instance of dotCMS running and a license pack installed, you can start up additional dotCMS container(s). From the same directory that you previous ran docker-compose, you do this by running a command like this:

docker-compose up -d --scale dotcms=2

While it is technically possible to scale up or down instances by more than one at a time, it is advisable at this time to only scale up or down one instance at a time. This is caused by the amount of time it takes to copy indexes, etc, and for the system to be in a stable state ready for additional scaling. Larger installations may be able to scale things up or down by more than increments of one but please consult with us before planning on scaling up or down that quickly.