Welcome to the official OpenCms Docker image maintained by Alkacon.
Here you find a Docker Compose setup with a ready to use OpenCms installation including Jetty and MariaDB.
OpenCms can be used with other databases as described below.
Images for older OpenCms versions are also available, see here.
Save the following docker-compose.yml file to your host machine.
services:
mariadb:
image: mariadb:latest
container_name: mariadb
init: true
restart: always
volumes:
- ~/dockermount/opencms-docker-mysql:/var/lib/mysql
environment:
- "MYSQL_ROOT_PASSWORD=secretDBpassword"
opencms:
image: alkacon/opencms-docker:20.1
container_name: opencms
init: true
restart: always
depends_on: [ "mariadb" ]
links:
- "mariadb:mysql"
ports:
- "80:8080"
volumes:
- ~/dockermount/opencms-docker-webapps:/container/webapps
command: ["/root/wait-for.sh", "mysql:3306", "-t", "30", "--", "/root/opencms-run.sh"]
environment:
- "DB_PASSWD=secretDBpassword"
Change the MariaDB root password secretDBpassword.
Adjust the following directories for your host system:
~/dockermount/opencms-docker-mysqlthe directory where all MariaDB data are persisted~/dockermount/opencms-docker-webappsthe Tomcat webapps directory that contains important configurations, caches and indices of OpenCms
Configured in this way, it is possible to upgrade the opencms and mariadb containers while keeping all your OpenCms and MariaDB data. See the upgrade guide below.
On the other hand, if you like to start with a completely fresh OpenCms installation, do not forget to delete both mounted directories before.
Navigate to the folder with the docker-compose.yml file and execute docker-compose up -d.
Startup will take a while since numerous modules are installed.
You can follow the installation process with docker-compose logs -f opencms.
When the containers are set up, you can access the OpenCms workplace via http://localhost/system/login.
The default account is username Admin with password admin.
In addition to DB_PASSWD, the following environment variables are supported:
DB_HOST, the database host name, defaults tomysqlDB_USER, the database user, default isrootDB_PASSWD, the database password, is not set by defaultDB_PASSWD_FILE, file in the container where the database password is stored (/run/secrets/<secret_name>); to be used with docker composesecretsDB_NAME, the database name, default isopencmsADMIN_PASSWD, the admin password, defaults toadminADMIN_PASSWD_FILE, file in the container where the admin password is stored (/run/secrets/<secret_name>); to be used with docker composesecretsOPENCMS_COMPONENTS, the OpenCms components to install, default isworkplace,demo; to not install the demo template useworkplaceJETTY_OPTS, the Jetty startup options (in addition to predefined options), default is-Xmx2gDEBUG, flag indicating whether to enable verbose debug logging and allowing connections via {docker ip address}:8000, defaults tofalseJSONAPI, flag indicating whether to enable the JSON API, default isfalseSERVER_URL, the server URL, default ishttp://localhost
The variables DB_PASSWD and DB_PASSWD_FILE respectively ADMIN_PASSWD and ADMIN_PASSWD_FILE are alternatives. Read more about docker compose secrets here.
Before upgrading the image, make sure that you have persisted your OpenCms data and MariaDB data with Docker volumes as described above. Otherwise you will lose your data.
When upgrading from an older version of this image, read the image history below at first.
Enter the target version of the OpenCms image in your docker-compose.yml file.
opencms:
image: alkacon/opencms-docker:20.1
Navigate to the folder with the docker-compose.yml file and execute docker-compose up -d.
During startup, the Docker setup will update several modules as well as JAR files and configurations in the /container/webapps directory.
You can follow the installation process with docker compose logs -f opencms.
It is recommended to remove the /container/webapps/ROOT/WEB-INF/index folder after upgrade and do a full Solr reindex.
OpenCms uses a special configuration file called setup.properties to establish a database connection.
In order to connect to a database other than MariaDB, this image supports connection via a custom setup.properties file.
The file must be named custom-setup.properties and must be available in the root folder of the docker container.
An example setup for PostgreSQL can be found here.
For more information on the DB configuration options, see the OpenCms documentation.
Note: when using a custom configuration file, the environment variables DB_HOST, DB_USER, DB_PASSWD, DB_NAME, OPENCMS_COMPONENTS, SERVER_URL are ignored.
Since the image is available on Docker Hub, you do not need to build it yourself. If you want to build it anyway, here's how to do it:
Download the opencms-docker repository.
Go to the repository's main folder and type docker compose build opencms.
View the licence information on GitHub.