Introduction
The JS7 - Controller Installation for Docker Containers article explains start-up of a JOC Cockpit container using the Docker® Run
command.
The following examples apply for users who wish to start containers using the docker-compose
utility. Consider that examples have to be adjusted to individual environments.
Examples
...
Examples are have been contributed by the Japanese JS7 Community. Find the The complete instructions from can be found in the Start with JS7 JobScheduler docker-compose (MySQL version) article.
Preparation
Docker Compose Configuration: docker-compose.
...
yml
Download: docker-compose.yamlyml
Code Block |
---|
language | yml |
---|
title | Example for use of Docker Compose with MySQL |
---|
|
version: '3'
services:
db:
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
networks:
- js7
environment:
MYSQL_ROOT_PASSWORD: js7rootpassword
MYSQL_DATABASE: js7db
MYSQL_USER: js7user
MYSQL_PASSWORD: js7password
restart: "no"
js7-joc-primary:
depends_on:
- db
container_name: js7-joc-primary
image: sosberlin/js7:joc-${JS7VERSION}
hostname: js7-joc-primary
ports:
- "17446:4446"
networks:
- js7
volumes:
- js7-joc-primary-config:/var/sos-berlin.com/js7/joc/resources/joc
- js7-joc-primary-logs:/var/sos-berlin.com/js7/joc/logs
environment:
RUN_JS_JAVA_OPTIONS: -Xmx256m
RUN_JS_USER_ID: "${JS7USERID}:${JS7GROUPID}"
restart: "no"
networks:
js7:
external: true
volumes:
db_data:
driver: local
driver_opts:
type: none
device: ${PWD}/db_data
o: bind
js7-joc-primary-config:
driver: local
driver_opts:
type: none
device: ${PWD}/js7-joc-primary-config
o: bind
js7-joc-primary-logs:
driver: local
driver_opts:
type: none
device: ${PWD}/js7-joc-primary-logs
o: bind
|
Explanation:
- Use of volumes: There are a number of ways of mounting or binding volumes into a container.
- One strategy is to mount a Docker® volume which is managed by Docker®, typically in
/var/lib/docker/volumes
. - Another strategy is to map Docker® volumes to the local file system. This requires letting Docker® Compose know that the volume is locally managed and is the focus of the above example.
- Use of user accounts: see JS7 - Running Containers for User Accounts.
- The
RUN_JS_USER_ID
setting holds the User ID and Group ID. Consider that the Group ID has to be 0 as directories and files in the image are owned by the root group.
Hibernate Configuration: hibernate.cfg.xml
...
Code Block |
---|
language | xml |
---|
title | Example of hibernate.cfg.xml for MySQL |
---|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.mariadb.jdbc.Driver</property>
<property name="hibernate.connection.password">js7password</property>
<property name="hibernate.connection.url">jdbc:mariadb://db:3306/js7db</property>
<property name="hibernate.connection.username">js7user</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
<property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
<property name="hibernate.hikari.maximumPoolSize">10</property>
</session-factory>
</hibernate-configuration> |
Environment Variables used with the Examples
Code Block |
---|
language | bash |
---|
title | Environment Variables used with the Examples |
---|
|
echo -e "JS7USERID=$(id -u)\nJS7GROUPID=$(id -g)\nJS7VERSION=2-5-0" > .env
# check environment variables
cat .env
JS7USERID=1000
JS7GROUPID=0
JS7VERSION=2-5-0 |
Directories used with the Examples
Code Block |
---|
language | bash |
---|
title | Directories used with the Examples |
---|
|
mkdir db_data
mkdir js7-joc-primary-config
mkdir js7-joc-primary-logs |
Directory Hierarchy
Code Block |
---|
language | bash |
---|
title | Directories used with the Examples |
---|
|
.
├── .env
├── db_data
├── docker-compose.yml
├── hibernate.cfg.xml
├── js7-joc-primary-config
└── js7-joc-primary-logs |
Container Start-up
Start Container
Code Block |
---|
language | bash |
---|
title | Example how to start up Containers |
---|
|
docker-compose up -d
# check containers
$ docker-compose ps
NAME COMMAND SERVICE STATUS PORTS
js74-db-1 "docker-entrypoint.s…" db running 33060/tcp
js74-js7-joc-primary-1 "sh /usr/local/bin/e…" js7-joc-primary running 0.0.0.0:4446->4446/tcp, :::4446->4446/tcp |
Copy Hibernate Configuration to Container
Code Block |
---|
language | bash |
---|
title | Example how to copy hibernate.cfg.xml to the Container |
---|
|
cp -f hibernate.cfg.xml js7-joc-primary-config/ |
Create Database Objects from Container
Code Block |
---|
language | bash |
---|
title | Example how to copy hibernate.cfg.xml to the Container |
---|
|
docker-compose exec js7-joc-primary /bin/sh -c /opt/sos-berlin.com/js7/joc/install/joc_install_tables.sh
# check installation log file
tail js7-joc-primary-logs/install-result.log |
Restart Container
Code Block |
---|
language | bash |
---|
title | Example how to restart the Container |
---|
|
# restart container
docker-compose restart js7-joc-primary |
Initial Operation
See JS7 - JOC Cockpit Installation for Docker Containers, section: Initial Operation.