如何在Jenkins Docker容器中挂载Azure应用服务存储? [英] How to mount Azure App Service storage in Jenkins Docker Container?

查看:120
本文介绍了如何在Jenkins Docker容器中挂载Azure应用服务存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Jenkins托管在Azure App Service的Docker容器中.这意味着它是"Linux"托管.

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

默认情况下,jenkins/jenkins-2.110-alpine Docker 图像将其数据存储在容器中的/var/jenkins_home文件夹中.我希望此数据/配置可持久保存到Azure持久性存储中,以便在容器重新启动后持久保存.

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.

所以我自定义了Jenkins Dockerfile看起来像这样...

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

但是,当我部署到Azure App Service时,在我的/home文件夹中看不到该文件(在Kudu控制台中查看).该应用程序启动正常,但是重新启动容器时我丢失了所有数据.

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.

我想念什么?

推荐答案

这是预期的,因为您仅在Azure主机上保留了符号链接(ln -s /var/jenkins_home /home/jenkins).所有文件实际上都存在于容器内. 为此,您必须实际更改Jenkins配置,以将所有数据存储在已经在上面的Dockerfile中创建的/home/jenkins中.

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.

快速搜索 Jenkins数据文件夹,建议您设置环境变量JENKINS_HOME到您的目录. 在您的Dockerfile:

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

这篇关于如何在Jenkins Docker容器中挂载Azure应用服务存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆