-
Notifications
You must be signed in to change notification settings - Fork 58
Description
I am trying to extend your Virtuoso Docker Image to just include a non-root user to run Virtuoso in a Docker Container.
FROM tenforce/virtuoso:latest
ARG USER_ID=1000
ARG GROUP_ID=1000
RUN groupadd \
--gid $GROUP_ID \
my_group; \
useradd \
--home-dir /home/my_non_root_user \
--shell /bin/bash \
--create-home \
--uid $USER_ID \
--gid $GROUP_ID \
my_non_root_user;
USER my_non_root_user
The purpose of this is to allow for the files generated by the Docker image in the /data directory, which I mount to my host in order to have persistent storage. The above Dockerfile simply created a group and a user inside the Docker Image with the same UID and GID as my user on my host machine and then tells Docker to use that User for any following instructions, which include ENTRYPOINT and CMD Dockerfile instructions, which I don't override. At container start up the parent Docker image's ENTRYPOINT and CMD will be run by my new, non-root User.
Unfortunately, I am having trouble with this because the virtuoso.sh script that is run as the CMD instruction requires and depends on the root user running it to create some files. I figured this out by checking the docker logs. This is my output from docker logs:
mkdir: cannot create directory '/settings': Permission denied
chmod: changing permissions of '/clean-logs.sh': Operation not permitted
Converting environment variables to ini file
Finished converting environment variables to ini file
/virtuoso.sh: line 33: /settings/.config_set: No such file or directory
touch: cannot touch '/sql-query.sql': Permission denied
/virtuoso.sh: line 40: /sql-query.sql: Permission denied
/virtuoso.sh: line 41: /sql-query.sql: Permission denied
OpenLink Virtuoso Interactive SQL (Virtuoso)
Version 07.20.3229 as of Aug 22 2018
Type HELP; for help and EXIT; to exit.
Connected to OpenLink Virtuoso
Driver: 07.20.3229 OpenLink Virtuoso ODBC Driver
SQL> dump_nquads(0) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(1) dump_nquads(2) dump_nquads(2) dump_nquads(3) dump_nquads(3) dump_nquads(2) dump_nquads(2) dump_nquads(2) dump_nquads(2) dump_nquads(3) dump_nquads(3) dump_nquads(3) dump_nquads(3) dump_nquads(4) dump_nquads(4) dump_nquads(4) dump_nquads(3) dump_nquads(3) dump_nquads(3) dump_nquads(3) dump_nquads(2) dump_nquads(2) dump_nquads(1) dump_nquads(1) dump_nquads(2) dump_nquads(2) dump_nquads(2) dump_nquads(2) dump_nquads(3) dump_nquads(3) dump_nquads(3) dump_nquads(2) dump_nquads(2) dump_nquads(2) dump_nquads(1)
Done. -- 1 msec.
/virtuoso.sh: line 42: /sql-query.sql: No such file or directory
Wed Apr 24 2019
10:49:10 OpenLink Virtuoso Universal Server
10:49:10 Version 07.20.3229-pthreads for Linux as of Aug 22 2018
10:49:10 uses parts of OpenSSL, PCRE, Html Tidy
10:49:10 Database version 3126
10:49:10 SQL Optimizer enabled (max 1000 layouts)
10:49:11 Compiler unit is timed at 0.000169 msec
10:49:11 Roll forward started
10:49:11 Roll forward complete
10:49:12 Checkpoint started
10:49:12 Checkpoint finished, log reused
10:49:14 HTTP/WebDAV server online at 8890
10:49:14 Server online at 1111 (pid 1)
10:50:41 Incorrect login for dba from IP [127.0.0.1]
10:51:47 Incorrect login for dba from IP [127.0.0.1]
10:51:53 Incorrect login for dba from IP [127.0.0.1]
10:53:00 Incorrect login for dba from IP [127.0.0.1]
While Virtuoso still runs as the non-root user, the actions in the virtuoso.sh script do not behave correctly, so I am losing out on a lot of the functionality you have set up. For example, setting up a DBA_PASSWORD via environment variables to the Docker container and configuring the virtuoso.ini file via environment variables. As you can see, when I try to login with the DBA_PASSWORD I am expecting to work, it doesn't.
It may be as easy as just changing where the /settings directory, /settings/.config_set file, clean-logs.sh script, and sql-query.sql script are made, but that is just a guess based off the logs I provided.
If you have another idea/suggestion, please let me know as I would love to be able to run virtuoso as a non-root user in my environment.