oci-oracle-xe icon indicating copy to clipboard operation
oci-oracle-xe copied to clipboard

Proper way to mount host directory to be used as Oracle Directory

Open ognjenk opened this issue 1 year ago • 1 comments

Hi,

I have an application which is supposed to use a couple of different Oracle Directories for some XML file processing duties. I am running into trouble setting up these directories and using them in the docker image.

I have tried creating a directory on my Ubuntu host, mounting it as a volume in docker with -v switch in my docker run script -v /u01/my_files:/opt/oracle/my_files and then creating a directory in Oracle with create directoy MYDIR AS '/opt/oracle/my_files';

This creates the directory in the image, and this dir can be used for reading the files, however I cannot write files to it. As far as I understand, the dir in image is created with user UID 1001, so oracle user does not have the correct permission to write to it.

When I try this with some existing directory in the image (e.g. /opt/oracle/admin/XE/dpdump/FABB974710DF0B1EE0536402000AC34B which is default DP directory) and I mount some dir from my host to this dir, everything works correctly. I assume because this dir already exists in the container and has correct read/write permissions.

So, my question would be, what is the preferred way to create additional directories in the image that can be mounted on the host and used as Oracle DIRECTORY paths? I could use the default DP dir for everything, but would prefer to be able to set up 3 different directories to organize my XML file data.

Thanks in advance!

ognjenk avatar Jun 19 '23 15:06 ognjenk

Hi @ognjenk,

Thanks a lot for using these images!

I think your conclusion is correct, using -v will create a new directory with probably the root user as the owner. I see a couple of solutions to that situation:

  1. Extend the image with pre-created directories and perhaps also already pre-created Oracle Database directory objects
  2. See whether the -v option provides any way to either change the ownership or permissions of the mounted directory
  3. Make sure that the mounted directory /u01/my_files already has the correct ownership

I don't think there is a right or wrong for any of these options. -v is simply a Linux mount operation (as least that's how it was explained to me many years ago by a Docker engineer) and with that come the usual Linux permission questions and issues. The fact that the container isn't running under root and shouldn't be running under root anyway, further complicates things.

My personal preference would be to use Option 3 if you happen to be on a Mac on Linux environment, by doing a chmod -R 777. Windows, however, I've heard further complicates this with its Samba driver not passing on the right permissions either.

Hope this helps!

gvenzl avatar Sep 24 '23 18:09 gvenzl