<p>I am following the following <a href="https://learn.microsoft.com/en-us/azure/aks/jenkins-continuous-deployment" rel="nofollow noreferrer">doc</a> to deploy to Kubernetes from Jenkins. I have installed jenkins in my own VM. But getting following error when build is run</p>

<pre><code>+ docker build -t myregistry.azurecr.io/my-svc:latest7 ./my-svc
cannot create user data directory: /var/lib/jenkins/snap/docker/321: Read-only file system
Build step 'Execute shell' marked build as failure
Finished: FAILURE
</code></pre>

<p>However all the directories have jenkins use as the owner, I am not sure why it is getting into permission issues.</p>

<pre><code>poc@poc-ubuntu:~$ ls -ltr     /var/lib/
drwxr-xr-x 18 jenkins       jenkins       4096 Feb 18 16:45 jenkins
</code></pre>

<p>Was running into the same <em>exact</em> issue. Here's the workaround (from user Gargoyle (g-rgoyle) <a href="https://bugs.launchpad.net/snapcraft/+bug/1620771" rel="nofollow noreferrer">here</a>) that worked for me:</p>

<ol>
<li>Stop Jenkins: <code>service jenkins stop</code></li>
<li>Manually change Jenkins home dir: <code>mv /var/lib/jenkins /home/jenkins</code></li>
<li>Change jenkins users homedir in (might not be necessary after #2): <code>usermod -m -d /home/jenkins jenkins</code></li>
<li>Set homedir in Jenkins config: <code>nano /etc/default/jenkins</code> then go down to variable "<code>JENKINS_HOME</code>" and set value to "<code>/home/$NAME</code>"</li>
<li>Start Jenkins: <code>service jenkins start</code></li>
</ol>
