How to start Virtuoso Docker image in foreground mode with existing database volume

What

The Virtuoso Docker Images can be started in foreground mode from a bash shell command prompt and attached to an existing database Volume.

Why

If a Virtuoso database running in a docker container crashes/stopped etc this will result in the docker image itself being terminated and restarted by docker/swarm/kubernetes to keep the image running, as is the requirement for it running as micro service. If the database is crashing and you want to review kernel log or analyse core files etc you do not want the docker image to terminate and restart as these system logs/files would be lost.

How

A Virtuoso docker image can be started from a bash shell in foreground mode with a command of the form:

$ docker run \
    --name virtd \
    --interactive \
    --tty \
    --env DBA_PASSWORD=mysecret \
    --publish 1111:1111 \
    --publish  8890:8890 \
    --volume `pwd`:/database \
    openlink/virtuoso-closedsource-8:latest \
    bash

If the location pointed to by --volume contains an existing database and INI file etc the docker image with be automatically instantiated in a bash shell running in foreground mode:

$ docker run --name virtd --interactive --tty --env DBA_PASSWORD=mysecret --publish 1111:1111 --publish  8890:8890 --volume `pwd`:/database  openlink/virtuoso-closedsource-8:latest bash

  Fri Jul 12 2019 
11:06:28 { Loading plugin 1: Type `plain', file `geos' in `../hosting' 
11:06:28   plain version 1.0.3314 from OpenLink Software 
11:06:28   GEOS plugin based on Geometry Engine Open Source library from Open Source Geospatial Foundation 
11:06:28   SUCCESS plugin 1: loaded from ../hosting/geos.so } 
11:06:28 { Loading plugin 2: Type `plain', file `im' in `../hosting' 
11:06:28   IM version 0.63 from OpenLink Software 
11:06:28   Support functions for Image Magick 6.9.9 
11:06:28   SUCCESS plugin 2: loaded from ../hosting/im.so } 
11:06:28 { Loading plugin 3: Type `plain', file `proj4' in `../hosting' 
11:06:28   plain version 1.0.3314 from OpenLink Software 
11:06:28   Cartographic Projections support based on Frank Warmerdam's proj4 library 
11:06:28   SUCCESS plugin 3: loaded from ../hosting/proj4.so } 
11:06:28 { Loading plugin 4: Type `plain', file `qrcode' in `../hosting' 
11:06:28   QRcode version 0.1 from OpenLink Software 
11:06:28   Support functions for ISO/IEC 18004:2006, using QR Code encoder (C) 2006 Kentaro Fukuchi <fukichi@megaui.net> 
11:06:28   SUCCESS plugin 4: loaded from ../hosting/qrcode.so } 
11:06:28 { Loading plugin 5: Type `plain', file `shapefileio' in `../hosting' 
11:06:28   ShapefileIO version 0.1virt71 from OpenLink Software 
11:06:28   Shapefile support based on Frank Warmerdam's Shapelib 
11:06:28   SUCCESS plugin 5: loaded from ../hosting/shapefileio.so } 
11:06:28 OpenLink Virtuoso Universal Server 
11:06:28 Version 08.03.3314-pthreads for Linux as of May 24 2019 
11:06:28 uses parts of OpenSSL, PCRE, Html Tidy 
11:06:28 Registered to OpenLink Software (INTERNAL USE ONLY)
11:06:28 Personal Edition license for 500 connections
11:06:28 Issued by OpenLink Software
11:06:28 This license will expire on Sat Apr 11 14:23:48 2020 GMT
11:06:28 Enabled Cluster Extension
11:06:28 Enabled Column Store Extension
11:06:28 Enabled Virtual Database Extension
11:06:28 Enabled Replication Extension
11:06:28 Enabled Scalable ACL Extension
11:06:28 Enabled Custom Reasoning & Inference Rules 
11:06:28 Database version 3126 
11:06:28 SQL Optimizer enabled (max 1000 layouts) 
11:06:29 Compiler unit is timed at 0.000126 msec 
11:06:30 Roll forward started 
11:06:30 Roll forward complete 
11:06:31 Checkpoint started 
11:06:31 Checkpoint finished, log reused 
11:06:31 HTTP/WebDAV server online at 8890 
11:06:31 Server online at 1111 (pid 16) 
11:06:32 ZeroConfig registration virtuoso (07EEE1A090D7) 

and if the location pointed to by --volume does not contain an existing database (ie an empty volume) then a base Virtuoso docker installation with an empty database can be started by running the command /virtuoso-entrypoint.sh start as follows:

$ docker run --name virtd --interactive --tty --env DBA_PASSWORD=mysecret --publish 1111:1111 --publish  8890:8890 --volume `pwd`:/database  openlink/virtuoso-closedsource-8:latest bash
root@07eee1a090d7:/opt/virtuoso/database# pwd 
/opt/virtuoso/database 
root@07eee1a090d7:/opt/virtuoso/database# ls 
root@07eee1a090d7:/opt/virtuoso/database# 
root@07eee1a090d7:/opt/virtuoso/database# /virtuoso-entrypoint.sh start 
Creating initial database directory 

- Configuring: database 
  - Creating directory $VIRTUOSO_HOME/database/backup 
  - Creating directory $VIRTUOSO_HOME/database/logs 
  - Installing new virtuoso.ini in $VIRTUOSO_HOME/database 
  - Installing new php.ini in $VIRTUOSO_HOME/database 
  - Creating symlink to $VIRTUOSO_HOME/bin/virtuoso-iodbc-t 
Checking Plugins section 
Applying settings to virtuoso.ini 
Generating password 
Registering ODBC driver 
Creating initial database 

  Fri Jul 12 2019 
11:06:14 { Loading plugin 1: Type `plain', file `geos' in `../hosting' 
11:06:14   plain version 1.0.3314 from OpenLink Software 
11:06:14   GEOS plugin based on Geometry Engine Open Source library from Open Source Geospatial Foundation 
11:06:14   SUCCESS plugin 1: loaded from ../hosting/geos.so } 
11:06:14 { Loading plugin 2: Type `plain', file `im' in `../hosting' 
11:06:14   IM version 0.63 from OpenLink Software 
11:06:14   Support functions for Image Magick 6.9.9 
11:06:14   SUCCESS plugin 2: loaded from ../hosting/im.so } 
11:06:14 { Loading plugin 3: Type `plain', file `proj4' in `../hosting' 
11:06:14   plain version 1.0.3314 from OpenLink Software 
11:06:14   Cartographic Projections support based on Frank Warmerdam's proj4 library 
11:06:14   SUCCESS plugin 3: loaded from ../hosting/proj4.so } 
11:06:14 { Loading plugin 4: Type `plain', file `qrcode' in `../hosting' 
11:06:14   QRcode version 0.1 from OpenLink Software 
11:06:14   Support functions for ISO/IEC 18004:2006, using QR Code encoder (C) 2006 Kentaro Fukuchi <fukichi@megaui.net> 
11:06:14   SUCCESS plugin 4: loaded from ../hosting/qrcode.so } 
11:06:14 { Loading plugin 5: Type `plain', file `shapefileio' in `../hosting' 
11:06:14   ShapefileIO version 0.1virt71 from OpenLink Software 
11:06:14   Shapefile support based on Frank Warmerdam's Shapelib 
11:06:14   SUCCESS plugin 5: loaded from ../hosting/shapefileio.so } 
11:06:14 OpenLink Virtuoso Universal Server 
11:06:14 Version 08.03.3314-pthreads for Linux as of May 24 2019 
11:06:14 uses parts of OpenSSL, PCRE, Html Tidy 
11:06:14  
11:06:14 License not found 
11:06:14 Please make sure it is installed correctly 
11:06:14 If you did not receive a license file, 
11:06:14 contact sales@openlinksw.com or visit www.openlinksw.com 
11:06:14 and a new license will be made available to you 
11:06:14  
11:06:14 Demo license enabled 
11:06:14  
11:06:14 SQL Optimizer enabled (max 1000 layouts) 
11:06:15 Compiler unit is timed at 0.000106 msec 
11:06:19 Checkpoint started 
11:06:19 Roll forward started 
11:06:19 Roll forward complete 
11:06:19 Checkpoint started 
11:06:19 Checkpoint finished, log reused 
11:06:19 Checkpoint started 
11:06:19 Checkpoint finished, log reused 
11:06:20 Checkpoint started 
11:06:20 Checkpoint finished, log reused 
11:06:20 Checkpoint started 
11:06:20 Checkpoint finished, log reused 
11:06:20 Checkpoint started 
11:06:20 Checkpoint finished, log reused 
11:06:20 PL LOG: Installing Virtuoso Conductor version 1.00.8796 (DAV) 
11:06:20 PL LOG: Installing with dependencies Virtuoso Conductor version 1.00.8796/2019-05-24 18:13 (DAV) 
11:06:20 Checkpoint started 
11:06:21 Checkpoint finished, log reused 
11:06:24 Checkpoint started 
11:06:24 Checkpoint finished, log reused 
11:06:24 PL LOG: Installation with dependencies complete 
11:06:24 PL LOG: Initializing DB.DBA.SYS_PROJ4_SRIDS 
11:06:24 PL LOG: ... checking for data files in "/usr/share/proj" 
11:06:25 PL LOG: DB.DBA.SYS_PROJ4_SRIDS now contains 8650 spatial reference systems 
11:06:25 Checkpoint started 
11:06:25 Checkpoint finished, log reused 
11:06:25 Server exiting 
Setting passwords 

  Fri Jul 12 2019 
11:06:28 { Loading plugin 1: Type `plain', file `geos' in `../hosting' 
11:06:28   plain version 1.0.3314 from OpenLink Software 
11:06:28   GEOS plugin based on Geometry Engine Open Source library from Open Source Geospatial Foundation 
11:06:28   SUCCESS plugin 1: loaded from ../hosting/geos.so } 
11:06:28 { Loading plugin 2: Type `plain', file `im' in `../hosting' 
11:06:28   IM version 0.63 from OpenLink Software 
11:06:28   Support functions for Image Magick 6.9.9 
11:06:28   SUCCESS plugin 2: loaded from ../hosting/im.so } 
11:06:28 { Loading plugin 3: Type `plain', file `proj4' in `../hosting' 
11:06:28   plain version 1.0.3314 from OpenLink Software 
11:06:28   Cartographic Projections support based on Frank Warmerdam's proj4 library 
11:06:28   SUCCESS plugin 3: loaded from ../hosting/proj4.so } 
11:06:28 { Loading plugin 4: Type `plain', file `qrcode' in `../hosting' 
11:06:28   QRcode version 0.1 from OpenLink Software 
11:06:28   Support functions for ISO/IEC 18004:2006, using QR Code encoder (C) 2006 Kentaro Fukuchi <fukichi@megaui.net> 
11:06:28   SUCCESS plugin 4: loaded from ../hosting/qrcode.so } 
11:06:28 { Loading plugin 5: Type `plain', file `shapefileio' in `../hosting' 
11:06:28   ShapefileIO version 0.1virt71 from OpenLink Software 
11:06:28   Shapefile support based on Frank Warmerdam's Shapelib 
11:06:28   SUCCESS plugin 5: loaded from ../hosting/shapefileio.so } 
11:06:28 OpenLink Virtuoso Universal Server 
11:06:28 Version 08.03.3314-pthreads for Linux as of May 24 2019 
11:06:28 uses parts of OpenSSL, PCRE, Html Tidy 
11:06:28 Registered to OpenLink Software (INTERNAL USE ONLY)
11:06:28 Personal Edition license for 500 connections
11:06:28 Issued by OpenLink Software
11:06:28 This license will expire on Sat Apr 11 14:23:48 2020 GMT
11:06:28 Enabled Cluster Extension
11:06:28 Enabled Column Store Extension
11:06:28 Enabled Virtual Database Extension
11:06:28 Enabled Replication Extension
11:06:28 Enabled Scalable ACL Extension
11:06:28 Enabled Custom Reasoning & Inference Rules 
11:06:28 Database version 3126 
11:06:28 SQL Optimizer enabled (max 1000 layouts) 
11:06:29 Compiler unit is timed at 0.000126 msec 
11:06:30 Roll forward started 
11:06:30 Roll forward complete 
11:06:31 Checkpoint started 
11:06:31 Checkpoint finished, log reused 
11:06:31 HTTP/WebDAV server online at 8890 
11:06:31 Server online at 1111 (pid 16) 
11:06:32 ZeroConfig registration virtuoso (07EEE1A090D7) 

Then when you type Ctrl ^C to stop the database running in foreground mode the docker container will not be removed and you are presented with a bash shell prompt for of the Virtuoso docker instance, enabling it to then be treated as a standalone installation without all the docker/kubernetes monitoring and restarting of the docker container:

11:06:31 HTTP/WebDAV server online at 8890 
11:06:31 Server online at 1111 (pid 16) 
11:06:32 ZeroConfig registration virtuoso (07EEE1A090D7) 
Crtl ^C
11:06:37 Server received signal 2 
11:06:37 Initiating normal shutdown 
11:06:37 Checkpoint started 
11:06:37 Checkpoint finished, log reused 
11:06:37 Server shutdown complete 
root@07eee1a090d7:/opt/virtuoso/database# ls -ltr 
total 66224 
-rw-r--r-- 1 root root        0 Jul 12 11:06 virtuoso.pxa 
-rw-r--r-- 1 root root     6547 Jul 12 11:06 virtuoso.ini 
-rw-r--r-- 1 root root      230 Jul 12 11:06 odbcinst.ini 
-rw-r--r-- 1 root root      262 Jul 12 11:06 odbc.ini 
drwxr-xr-x 2 root root       64 Jul 12 11:06 logs 
drwxr-xr-x 2 root root       64 Jul 12 11:06 backup 
-rw-r--r-- 1 root root  2097152 Jul 12 11:06 virtuoso-temp.db 
-rw-r--r-- 1 root root        0 Jul 12 11:06 virtuoso.trx 
-rw-r--r-- 1 root root     7952 Jul 12 11:06 virtuoso.log 
-rw-r--r-- 1 root root 65011712 Jul 12 11:06 virtuoso.db 
root@07eee1a090d7:/opt/virtuoso/database# 

Related