Skip to content
Other versions

Loading…

Using Docker

Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages software into standardized units called containers with everything the software needs to run, including libraries, system tools, code, and runtime. Using Docker, you can quickly deploy and scale applications into any environment and know that your code will run.

There is a public Docker image available at https://hub.docker.com/repository/docker/openkm/openkm-ce and it is the easiest way to get OpenKM running on your server.

Please refer to Docker documentation for installation instructions and to learn more about Docker.

Once Docker has been installed, create the proper openkm.properties file or configure it using the environment variables, and execute this command to get your OpenKM instance:

Terminal window
$ docker run --name openkm-ce -p 8080:8080 openkm/openkm-ce

And after that, point your browser to http://localhost:8080/. The default user and password are “okmAdmin” / “admin”.

This way, you can create a container with the default embedded H2 database (not recommended for production, but just fine for testing):

Terminal window
$ docker run -d --name openkm -p 8080:8080 -v myvol:/opt/tomcat \
    -e DATABASE_DRIVER=org.h2.Driver \
    -e DATABASE_URL=jdbc:h2:/opt/tomcat/okmdb \
    -e DATABASE_DIALECT=com.openkm.db.dialect.H2Dialect \
    --restart=unless-stopped openkm/openkm-ce:7.0.1

This is a sample that can be used to create a container using MySQL, but the recommended way is to use Docker Compose:

Terminal window
$ docker run -d --name openkm -p 8080:8080 -v myvol:/opt/tomcat \
    -e DATABASE_DRIVER="com.mysql.cj.jdbc.Driver" \
    -e DATABASE_URL="jdbc:mysql://172.17.0.1:3306/dbtest?useUnicode=true&characterEncoding=UTF8&serverTimezone=CET&nullNamePatternMatchesAll=true" \
    -e DATABASE_USER="openkm" \
    -e DATABASE_PASSWORD="openkm" \
    -e DATABASE_DIALECT="com.openkm.db.dialect.MySQL5InnoDBDialect" \
    --restart=unless-stopped openkm/openkm-ce:7.0.1

The database can be created this way:

CREATE USER 'openkm'@'%' IDENTIFIED BY 'openkm';
CREATE DATABASE dbtest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
GRANT ALL ON dbtest.* TO 'openkm'@'%' WITH GRANT OPTION;

To see the container logs:

Terminal window
$ docker logs -f openkm

To stop the container:

Terminal window
$ docker stop openkm

To start it again:

Terminal window
$ docker start openkm

To access the container:

Terminal window
$ docker exec -ti openkm bash

For more actions, please check the Docker documentation site.

These are the environment variables that can be used to configure the OpenKM container:

Variable Description
DATABASE_DRIVER The JDBC database driver connects to the database.
DATABASE_URL The JDBC URL to connect to the database.
DATABASE_USER The database user.
DATABASE_PASSWORD The database user’s password.
DATABASE_DIALECT The Hibernate database dialect.

To make all this configuration easy, we recommend using Docker Compose. Please refer to the Docker Compose documentation for installation instructions and more information.

This is a sample Docker Compose configuration file using environment variables, where MySQL is used as the database:

version: '3.2'
services:
openkm_mysql:
image: docker.openkm.com/private/professional:7.1.13
container_name: openkm_mysql
hostname: openkm
ports:
- 8080:8080
volumes:
- openkm_mysql:/opt/tomcat
environment:
- DATABASE_DRIVER=com.mysql.cj.jdbc.Driver
- DATABASE_URL=jdbc:mysql://mysql:3306/okmdb?useUnicode=true&characterEncoding=UTF8&serverTimezone=CET&nullNamePatternMatchesAll=true
- DATABASE_USER=openkm
- DATABASE_PASSWORD=openkm
- DATABASE_DIALECT=com.openkm.db.dialect.MySQL5InnoDBDialect
- TZ=Europe/Madrid
entrypoint: [ "wait-for-it.sh", "mysql:3306", "--timeout=0", "--strict", "--", "entrypoint.sh" ]
links:
- mysql:mysql
networks:
skynet:
ipv4_address: 172.28.1.1
mysql:
image: mysql:8.0.18
container_name: okmdb_mysql
hostname: mysql
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_bin
volumes:
- okmdb_mysql:/var/lib/mysql
environment:
- MYSQL_DATABASE=okmdb
- MYSQL_USER=openkm
- MYSQL_PASSWORD=openkm
- MYSQL_ROOT_PASSWORD=openkm
security_opt:
- seccomp:unconfined
networks:
skynet:
ipv4_address: 172.28.1.2
volumes:
openkm_mysql:
okmdb_mysql:
networks:
skynet:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16

 This is another sample Docker Compose configuration:

version: '3.2'
services:
openkm_mysql:
image: openkm/openkm-ce:7.0.1
container_name: openkm_mysql
hostname: openkm
ports:
- 8080:8080
volumes:
- ${PWD}/openkm.properties:/opt/tomcat/openkm.properties
- ${PWD}/repository:/opt/tomcat/repository
environment:
- TZ=Europe/Madrid
entrypoint: [ "wait-for-it.sh", "mysql:3306", "--timeout=0", "--strict", "--", "entrypoint.sh" ]
links:
- mysql:mysql
networks:
skynet:
ipv4_address: 172.28.1.1
mysql:
image: mysql:8.0.18
container_name: okmdb_mysql
hostname: mysql
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_bin
volumes:
- ${PWD}/mysql:/var/lib/mysql
environment:
- MYSQL_DATABASE=okmdb
- MYSQL_USER=openkm
- MYSQL_PASSWORD=openkm
- MYSQL_ROOT_PASSWORD=openkm
security_opt:
- seccomp:unconfined
networks:
skynet:
ipv4_address: 172.28.1.2
networks:
skynet:
ipam:
driver: default
config:
- subnet: 172.28.0.0/16

 This is the openkm.properties file:

# OpenKM Hibernate configuration values
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://mysql:3306/okmdb?useUnicode=true&characterEncoding=UTF8&serverTimezone=CET&nullNamePatternMatchesAll=true
spring.datasource.username=openkm
spring.datasource.password=openkm
# JPA stuff
spring.jpa.hibernate.ddl-auto=create-only
spring.jpa.properties.hibernate.dialect=com.openkm.db.dialect.MySQL5InnoDBDialect
# Cluster
cluster.enabled=false
cluster.node=master
# Logging config
spring.output.ansi.enabled=always