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:

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

Remember that you need a database in another container that the OpenKM container will use.

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):

$ 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

If you start a container that creates a new volume, as above, and the container has files in the directory to be mounted (like /opt/tomcat), the directory’s contents are copied into the volume. The container then mounts and uses the volume, so we can say the volume initially has pre-populated content from the image.

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

$ 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:

$ docker logs -f openkm

To stop the container:

$ docker stop openkm

To start it again:

$ docker start openkm

To access the container:

$ docker exec -ti openkm bash

For more actions, please check the Docker documentation site.

Configuration

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

VariableDescription

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.

Docker Compose

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
Table of contents [ Hide Show ]