简体   繁体   English

Jenkins在Docker上-持久数据

[英]Jenkins on Docker - Persist data

I have a docker container with a jenkins installation. 我有一个安装了jenkins的docker容器。 In order to persist the jenkins jobs, etc i have attached a disk and told jenkins to use it. 为了坚持詹金斯的工作,等等,我已经附上了一个磁盘,并告诉詹金斯使用它。 No problem so far. 到目前为止没有问题。

Now i have ssh into the machine to install the dotnet core cli. 现在我将ssh插入计算机以安装dotnet core cli。 I have installed dotnet on the attached disk. 我已经在连接的磁盘上安装了dotnet。 After that a run 在那之后

ln -s /dev/myDisk/dotnet/dotnet /usr/local/bin

to "register" the command. “注册”命令。 Works as expected. 可以正常工作。 But if i restart the node "dotnet" is no longer in the /usr/local folder. 但是,如果我重新启动,则节点“ dotnet”不再位于/ usr / local文件夹中。

It makes all sense to me. 这对我来说很有意义。

I have tried to find something but had no luck. 我试图找到一些东西,但是没有运气。

How can i run a script if the container starts or persist this data too ? 如果容器启动或也持久保存此数据,我如何运行脚本?

Changes to a running container are not committed to the image , so if you restart, the changes you made to the running container are not persisted. 对运行中的容器所做的更改不会提交给映像 ,因此,如果您重新启动,则对更改中的运行中容器所做的更改不会保留。

You have a few options: 您有几种选择:

  1. Create a new image in which .NET core is installed 创建一个安装了.NET Core的新映像

  2. Use the "official" .NET Core docker image as your base: https://github.com/dotnet/dotnet-docker 使用“官方” .NET Core Docker映像作为基础: https : //github.com/dotnet/dotnet-docker

More information on Docker filesystems here: https://docs.docker.com/engine/tutorials/dockervolumes/ 此处提供有关Docker文件系统的更多信息: https : //docs.docker.com/engine/tutorials/dockervolumes/

I ended up in 我最终进入

  • configuring my container (as before) 配置我的容器(像以前一样)
  • commit my changes to a new image 将更改提交到新映像
  • pushed the image to google container registry (docker hub would work too) 将图像推送到Google容器注册表(docker hub也可以工作)
  • changed my deployment to use the new image 更改了我的部署以使用新映像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM