How to start Virtuoso Docker image in bash shell with existing database volume mounted

What

The Virtuoso Docker Images can be started in a bash shell command prompt with an existing or new database Volume mounted.

Why

There are occasions when a manual connection to a Virtuoso docker image container is required to manual start the Virtuoso instance or perform other such administrative operations on the database from a bash terminal session, as if running a standalone installation.

This may be require to manually start the database in foreground mode, perform a manual database backup, database dump and restore operations or even diagnose crash conditions that maybe occurring on the database etc.

How

A Virtuoso docker image can be started in 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 and a bash terminal session to the running instance made:

$ docker run \
>     --name virt-bash \
>     --interactive \
>     --tty \
>     --env DBA_PASSWORD=mysecret \
>     --publish 1111:1111 \
>     --publish  8890:8890 \
>     --volume `pwd`:/database \
>     openlink/virtuoso-closedsource-8:latest \
>     bash
root@d7c0e035d4a3:/opt/virtuoso/database# pwd  
/opt/virtuoso/database
root@d7c0e035d4a3:/opt/virtuoso/database# ls -l
total 83860
drwxr-xr-x 2 root root       64 Jun  5  2020 backup
drwxr-xr-x 2 root root       64 Jun  5  2020 logs
-rw-r--r-- 1 root root      262 Jun  5  2020 odbc.ini
-rw-r--r-- 1 root root      230 Jun  5  2020 odbcinst.ini
-rwxr-xr-x 1 root root 18727880 Feb 21  2020 virtuoso-iodbc-t
-rw-r--r-- 1 root root  2097152 Nov 10 14:02 virtuoso-temp.db
-rw-r--r-- 1 root root 65011712 Nov 10 14:02 virtuoso.db
-rw-r--r-- 1 root root     6547 Jun  5  2020 virtuoso.ini
-rw-r--r-- 1 root root    13398 Nov 10 14:02 virtuoso.log
-rw-r--r-- 1 root root        0 Jun  5  2020 virtuoso.pxa
-rw-r--r-- 1 root root        0 Nov 10 14:02 virtuoso.trx
root@d7c0e035d4a3:/opt/virtuoso/database#

As can be seen a bash terminal session has been made to the Virtuoso docker container, which can now be administered as a standalone installation.

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 from the bash terminal session as follows:

$ docker run --name virt-bash --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 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 etc:

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