Docker: cannot create directory ‘/opt/jfrog/artifactory/logs’: Permission denied

dockerpermissions

I am trying to configure a docker image to run with a mounted volume, for persistence. The image is the official artifactory one. It seems odd to me that it will stop after creating several directories with a "Permission denied".

As I inspect the mounted volume, I can see that several folders were created when the image attempted to go up. And the database config is also ok.

Digging a bit, this guy seems to have permission issues artifactory:artifactory

However, I cannot go any further to the point I am able to explain or correct the problem.

---
Found java executable in JAVA_HOME (/usr/lib/jvm/java-8-openjdk-amd64)
mkdir: cannot create directory ‘/opt/jfrog/artifactory/logs’: Permission denied

** Could not create dir /opt/jfrog/artifactory/logs/catalina


Preparing to run Artifactory in Docker
=====================================
2017-03-17 12:51:17   [42 entrypoint-artifactory.sh] Checking open files and processes limits

2017-03-17 12:51:17   [45 entrypoint-artifactory.sh] Current max open files is 65536

2017-03-17 12:51:17   [57 entrypoint-artifactory.sh] Current max open processes is unlimited

2017-03-17 12:51:17   [67 entrypoint-artifactory.sh] Checking if /var/opt/jfrog/artifactory is mounted

2017-03-17 12:51:18   [72 entrypoint-artifactory.sh] /var/opt/jfrog/artifactory is mounted

2017-03-17 12:51:18   [78 entrypoint-artifactory.sh] Setting up data directories if missing

2017-03-17 12:51:18   [88 entrypoint-artifactory.sh] Create artifactory user if missing

2017-03-17 12:51:18   [94 entrypoint-artifactory.sh] User artifactory already exists

2017-03-17 12:51:18  [101 entrypoint-artifactory.sh] Checking permissions on /opt/jfrog/artifactory

2017-03-17 12:51:18  [110 entrypoint-artifactory.sh] /opt/jfrog/artifactory is already owned by artifactory:artifactory.

2017-03-17 12:51:18  [114 entrypoint-artifactory.sh] Checking permissions on /var/opt/jfrog/artifactory

2017-03-17 12:51:18  [120 entrypoint-artifactory.sh] /var/opt/jfrog/artifactory is owned by root:root. Setting to artifactory:artifactory.

2017-03-17 12:51:18  [246 entrypoint-artifactory.sh] Checking DB_TYPE

2017-03-17 12:51:18  [249 entrypoint-artifactory.sh] DB_TYPE is set to mysql

2017-03-17 12:51:18  [177 entrypoint-artifactory.sh] DB_HOST is set to x.y.s.w

2017-03-17 12:51:18  [179 entrypoint-artifactory.sh] Checking if need to copy mysql configuration

2017-03-17 12:51:18  [182 entrypoint-artifactory.sh] /var/opt/jfrog/artifactory/etc/db.properties already exists. Making sure it's set to mysql... 

2017-03-17 12:51:18  [185 entrypoint-artifactory.sh] /var/opt/jfrog/artifactory/etc/db.properties already set to mysql

2017-03-17 12:51:18  [154 entrypoint-artifactory.sh] Waiting for DB mysql to be ready on 104.196.117.4/3306 within 30 seconds

2017-03-17 12:51:18  [159 entrypoint-artifactory.sh] DB mysql up in 0 seconds
---
Found java executable in JAVA_HOME (/usr/lib/jvm/java-8-openjdk-amd64)
mkdir: cannot create directory ‘/opt/jfrog/artifactory/logs’: Permission denied

Best Answer

I had the same issue when sharing an nfs mount point as a volume. This resolved it:

docker-compose up --force-recreate

Hope that fixes your issue!