How to mount Azure App Service storage in Jenkins Docker Container?

五迷三道 提交于 2019-12-11 01:47:15

问题


I'm trying to host Jenkins in a Docker container in the Azure App Service. This means it's 'linux' hosting.

By default the jenkins/jenkins-2.110-alpine Docker image stores its data in the /var/jenkins_home folder in the container. I want this data/config persisted to Azure persistent storage so that it's persisted across container restarts.

I've read documentation and blogs stating that you can have container data persisted if it's stored in the /home folder.

So I've customized the Jenkins Dockerfile to look like this...

FROM jenkins/jenkins:2.110-alpine

USER root
RUN mkdir /home/jenkins
RUN ln -s /var/jenkins_home /home/jenkins
USER jenkins

However, when I deploy to Azure App Service I don't see the file in my /home folder (looking in Kudu console). The app starts just fine, but I lose all of my data when I restart my container.

What am I missing?


回答1:


That's expected because you only persist a symlink (ln -s /var/jenkins_home /home/jenkins) on the Azure host. All the files physically exist inside the container. To do this, you have to actually change Jenkins configuration to store all data in /home/jenkins which you have already created in your Dockerfile above.

A quick search for Jenkins data folder suggests that you set the environment variable JENKINS_HOME to your directory. In your Dockerfile:

ENV JENKINS_HOME /home/jenkins


来源:https://stackoverflow.com/questions/49212556/how-to-mount-azure-app-service-storage-in-jenkins-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!