<p>I am deploying my application in a kubernetes pod which is read-only in the cluster.
Also, in entrypoint.sh I am starting apache2 server using</p>
<pre><code>apachectl -D FOREGROUND
</code></pre>
<p>This is trying to create some folder in the read only pod resulting in this error:</p>
<pre><code>mktemp: failed to create directory via template '/var/lock/apache2.XXXXXXXXXX': Read-only file system
chmod: missing operand after '755'
</code></pre>
<p>How can I avoid this. Please note that I have tried to create this tmp file at the docker image creation time and applied that image and it is still giving same error.</p>

T Ravi Theja
<p>I don't think you can prevent Apache from creating this file.  The <a href="https://httpd.apache.org/docs/2.4/mod/core.html#defaultruntimedir" rel="nofollow noreferrer">DefaultRuntimeDir directive</a> changes its location, but you can't prevent it from creating its lock file.</p>
<p>What you can do, though, is mount an <a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="nofollow noreferrer"><code>emptyDir</code> volume</a> in your pod.  This is temporary writable pod-local storage.  That will let you create read-write &quot;islands&quot; within an otherwise read-only container filesystem.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      volumes:
        - name: apache-var-lock
          emptyDir: {}
      containers:
        - image: httpd
          volumeMounts:
            - name: apache-var-lock
              mountPath: /var/lock
</code></pre>
