<p>I have a Spring application built into a Docker image with the following command in <code>dockerfile</code></p>

<pre><code>CMD cd /opt/app/jar \
    &amp;&amp; java -Dspring.config.location=file:/opt/app/config/ -Dspring.profiles.active=test -jar *.jar
</code></pre>

<p>When creating app on OpenShift with </p>

<pre><code>oc new-app --name=test-app --docker-image=MyImage
</code></pre>

<p>and inspect the log with <code>oc logs &lt;pod_name&gt;</code>, I see this error:</p>

<pre><code>java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[LOGFILE] - Failed to create parent directories for [/opt/app/jar/../log/debug.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[LOGFILE] - openFile(/opt/app/jar/../log/debug.log,true) call failed. java.io.FileNotFoundException: /opt/app/jar/../log/debug.log (No such file or directory)
</code></pre>

<p>However, when I run the image directly with <code>docker run -it &lt;image_ID&gt; /bin/bash</code>, and then execute the <code>java -jar</code> command above, it runs fine.</p>

<p>Here is the snippet from my <code>logback.xml</code> file:</p>

<pre><code>&lt;appender name="LOGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
        &lt;file&gt;${user.dir}/../log/debug.log&lt;/file&gt;
        &lt;encoder&gt;
            &lt;pattern&gt;${FILE_LOG_PATTERN}&lt;/pattern&gt;
            &lt;charset&gt;utf8&lt;/charset&gt;
        &lt;/encoder&gt;
        &lt;rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"&gt;
            &lt;fileNamePattern&gt;${user.dir}/../log/archived/debug.%d{yyyy-MM-dd}.%i.log&lt;/fileNamePattern&gt;
            &lt;maxFileSize&gt;50MB&lt;/maxFileSize&gt;
            &lt;maxHistory&gt;10&lt;/maxHistory&gt;
        &lt;/rollingPolicy&gt;
    &lt;/appender&gt;
</code></pre>

<p>Could you please advise what I miss?</p>

<p>Versions I use:</p>

<pre><code>*# oc version
oc v3.7.14
kubernetes v1.7.6+a08f5eeb62
features: Basic-Auth GSSAPI Kerberos SPNEGO

# docker version
Client:
 Version:         1.12.6
 API version:     1.24
 Package version: docker-1.12.6-71.git3e8e77d.el7.x86_64
 Go version:      go1.8.3
 Git commit:      3e8e77d/1.12.6
 Built:           Wed Dec 13 12:18:58 2017
 OS/Arch:         linux/amd64

Server:
 Version:         1.12.6
 API version:     1.24
 Package version: docker-1.12.6-71.git3e8e77d.el7.x86_64
 Go version:      go1.8.3
 Git commit:      3e8e77d/1.12.6
 Built:           Wed Dec 13 12:18:58 2017
 OS/Arch:         linux/amd64*
</code></pre>

<p>Is it possible that it is an issue with permissions?</p>

<p>Unless something has changed...for better security OpenShift by default runs containers using a user with random UID; that user is a member of the root group.</p>

<p>So, in addition to the command @Rico suggested to be added to Dockerfile, I would add:</p>

<pre><code>RUN mkdir -p /opt/app/log \
 &amp;&amp; chown -R :root /opt/app/log \
 &amp;&amp; chmod -R 0775 /opt/app/log
</code></pre>

<p>This <a href="https://apisimulator.io/run-docker-containers-non-root-users-random-user-ids/" rel="nofollow noreferrer">blog article</a> has more info about running Docker containers with non-root users or random user IDs. (Disclaimer: I am affiliated with that web site)</p>
