How to fix Jira Docker Container Permission denied for dbconfig.xml?

Frank Becker November 25, 2019

I use vagrant to setup a docker container with the following lines

    d.run "jira",

      image: "atlassian/jira-software",

      args: " -p 8084:8080 -m 2GiB" +

      " --network jiranet" +

      " -e ATL_PROXY_NAME=192.168.50.4" +

      " -e ATL_PROXY_PORT=8084" +

      " -e ATL_TOMCAT_CONTEXTPATH=jira" 

 

During setup I get the following RuntimeIOException.

com.atlassian.jira.util.RuntimeIOException: Error writing database configuration file.
	at com.atlassian.jira.config.database.AbstractJiraHomeDatabaseConfigurationLoader.saveDatabaseConfiguration(AbstractJiraHomeDatabaseConfigurationLoader.java:74) [classes/:?]
	at 
.
.
.
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.42] at java.lang.Thread.run(Unknown Source) [?:1.8.0_232] Caused by: java.io.FileNotFoundException: /var/atlassian/application-data/jira/dbconfig.xml (Permission denied) at java.io.FileOutputStream.open0(Native Method) [?:1.8.0_232] at java.io.FileOutputStream.open(Unknown Source) [?:1.8.0_232] at java.io.FileOutputStream.<init>(Unknown Source) [?:1.8.0_232] at java.io.FileOutputStream.<init>(Unknown Source) [?:1.8.0_232] at java.io.FileWriter.<init>(Unknown Source) [?:1.8.0_232] at com.atlassian.jira.config.database.AbstractJiraHomeDatabaseConfigurationLoader.getWriter(AbstractJiraHomeDatabaseConfigurationLoader.java:89) [classes/:?] at com.atlassian.jira.config.database.AbstractJiraHomeDatabaseConfigurationLoader.saveDatabaseConfiguration(AbstractJiraHomeDatabaseConfigurationLoader.java:70) [classes/:?] ... 150 more

Here the ls for the dir

docker exec jira ls -al /var/atlassian/application-data/jira

total 48

drwxr-xr-x 11 jira jira 4096 Nov 25 18:47 .

drwxr-xr-x  1 root root 4096 Nov 20 21:16 ..

drwxr-x---  3 jira jira 4096 Nov 25 18:45 caches

drwxr-x---  3 jira jira 4096 Nov 25 18:45 data

drwxr-x---  2 jira jira 4096 Nov 25 18:47 database

-rw-r--r--  1 root root  999 Nov 25 18:45 dbconfig.xml

drwxr-x---  2 jira jira 4096 Nov 25 18:45 export

drwxr-x---  4 jira jira 4096 Nov 25 18:45 import

-rw-r-----  1 jira jira    0 Nov 25 18:45 .jira-home.lock

drwxr-x---  2 jira jira 4096 Nov 25 18:47 log

drwxr-x---  5 jira jira 4096 Nov 25 18:45 plugins

drwxr-xr-x  2 root root 4096 Nov 25 18:45 __pycache__

drwxr-x---  3 jira jira 4096 Nov 25 18:45 tmp

 

1 answer

1 accepted

0 votes
Answer accepted
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 5, 2019

Hi Frank,

I see that you're using a Jira Server inside a docker container and you can't seem to get Jira to start up.  Thanks for posting all this information.  I can see exactly what the problem is.

Jira is setup to run as a local user called 'jira'.  However the dbconfig.xml file has been created and is owned by the user 'root'.  Hence the jira user can't see this file to use it on startup.   As such you will need to change the permissions on that file back to the jira user.  Steps to do that are in How to fix directory permissions in Linux for Jira Server.  

Go to a terminal prompt and run this command to see which user account is logged in:

whoami

If you are logged in as the jira user, then run

id -g -n

In order to find the name of that group.

With that information you can then run the following to give that jira user permissions on all the files in the needed directories:

sudo chown -R jirauser:jiragroup /path/to/jirahome
sudo chown -R jirauser:jiragroup /path/to/jirainstall

chmod -R u=rwx,g=rx,o=rx /path/to/jirahome
chmod -R u=rwx,g=rx,o=rx /path/to/jirainstall

Where you will have to input the jirauser, jiragroup, as well as the $JIRAHOME/ and $JIRAINSTALL/ paths in your environment here.

Once that is done, you should be able to start up Jira and move past this problem.

Let me know if you have any questions about this.

Andy

Frank Becker December 5, 2019

HI Andy,

my docker hast is a virtual box installed by vagrant. So the user and the group are vagrant.

this is my setup 

config.vm.provision "shell", inline: "/vagrant/jira/presetup.sh"
config.vm.provision "docker" do |d|
d.run "jira",
image: "atlassian/jira-software",
args: " -p 8084:8080" +
" -e ATL_PROXY_NAME=192.168.50.4" +
" -e ATL_PROXY_PORT=8084" +
" -e ATL_TOMCAT_CONTEXTPATH=jira" 
" -v jiraVolume:/var/atlassian/application-data/jira"
end

  Here the presetup.sh

#!/bin/bash

volName=`docker volume list | grep "jiraVolume" | awk '{print $2}'`
if [[ ! -z "$volName" ]]
then
echo "delete volume $volName"
docker volume rm $volName
fi
docker volume create --name jiraVolume

 Last month I got the error but now the  dbconfig.xml is owned by user root and now  the user is jira. and the database setup finish correctly.

Now the file __pycache__ is the only file with user is root.

 

Think that this was fixed in the image now.

 

Frank

 

Suggest an answer

Log in or Sign up to answer