docker volume permission issue

I am trying to launch an app, deployed using wildfly18 in a docker container, which internally connects to my host postgresql database installation. During the container creation process, I am also mapping my container’s wildfly log directory to my local i.e "host" directory via a named volume, created using the docker volume create command.

The issue is, I get a "permission denied" error when the app runs and the container tries to create log files inside the mapped volume.

My Dockerfile contents are as below:

FROM jboss/base-jdk:8

ENV WILDFLY_SHA1=ef0372589a0f08c36b15360fe7291721a7e3f7d9
ENV JBOSS_HOME /opt/jboss/wildfly

USER root

    && curl -O$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz 
    && sha1sum wildfly-$WILDFLY_VERSION.tar.gz | grep $WILDFLY_SHA1 
    && tar xf wildfly-$WILDFLY_VERSION.tar.gz 
    && rm wildfly-$WILDFLY_VERSION.tar.gz 

COPY ./bin $JBOSS_HOME/bin
COPY ./standalone/configuration/* $JBOSS_HOME/standalone/configuration/
COPY ./modules/com $JBOSS_HOME/modules/com
COPY ./modules/system/layers/base/org/ $JBOSS_HOME/modules/system/layers/base/org/
COPY ./standalone/waffle_resource $JBOSS_HOME/standalone/waffle_resource
COPY ./standalone/waffle_resource/waffle.ear $JBOSS_HOME/standalone/deployments/
COPY ./standalone/waffle_resource/waffle-war.ear $JBOSS_HOME/standalone/deployments/

RUN chown -R jboss:jboss ${JBOSS_HOME} && chmod -R g+rw ${JBOSS_HOME}


USER jboss

EXPOSE 8989 9990


CMD ["/opt/jboss/wildfly/bin/", "-b", ""]

As you can see above, I am using user JBOSS inside the container to kick off wildfly.
The commands used to create an image and run a container and also to create a volume are as below:

docker image build -t viaduct/wildfly .

docker volume create viaduct-wildfly-logs

docker run -d -v viaduct-wildfly-logs:/opt/jboss/wildfly/standalone/log --network=host 
  -e "DB_DBNAME=dbname" 
  -e "DB_PORT=5432" 
  -e "DB_USER=xyz" 
  -e "DB_PASS=" 
  -e "DB_HOST=" 
  --name petes viaduct/wildfly

I verified the permissions within the container and my local "host" directory created by docker volume create command. Also, it’s worth noting,

I am running wildlfy as user JBOSS


The containers permissions are as below:

[[email protected] /]$ ll /opt/jboss/wildfly/standalone/
total 4
drwxrwxr-x 1 jboss jboss   62 Sep 18 00:24 configuration
drwxr-xr-x 6 jboss jboss   84 Sep 18 00:23 data
drwxrwxr-x 1 jboss jboss   64 Sep 18 00:24 deployments
drwxrwxr-x 1 jboss jboss   17 Nov 15  2019 lib
*drwxr-xr-x 2 root  root     6 Sep 17 23:48 log*
drwxrwxr-x 1 jboss jboss 4096 Sep 18 00:24 tmp
drwxrwxr-x 1 jboss jboss   98 Sep 18 00:23 waffle_resource
[[email protected] /]$ exit

and the local volume permissions are as below:

[[email protected] xyz]# cd /var/lib/docker/volumes/
[[email protected] volumes]# ll
drwxrwsr-x 3 root root    19 Sep 18 11:48 viaduct-wildfly-logs

The docker volume create command creates directory in my local machine as below:


and the permissions for each subdirectories by default are as follows, which definitely is for maintained for security reasons:

drwx--x--x  14 root root   182 Sep 14 09:32 docker
drwx------  7 root root   285 Sep 18 11:48 volumes
drwxrwsr-x 3 root root    19 Sep 18 11:48 viaduct-wildfly-logs

To start with, please let me know whether my strategy is correct?

Secondly, let me know the best way to fix the permission issue?

Source: Docker Questions