在Jenkins管道中为docker容器添加额外的运行参数

时间:2021-10-12 16:05:19

In my Jenkins Pipeline I declare an agent like:

在我的Jenkins管道中,我声明了一个代理:

agent{dockerfile true}

My Dockerfile is in the root of the source repository and I dont want to change that.

我的Dockerfile位于源存储库的根目录中,我不想更改它。

Now my question is: How can I provide additional Arguments when Jenkins is running the Container? I have to mount the Docker Socket (for running docker commands in my Pipeline) like:

现在我的问题是:当Jenkins运行Container时,如何提供额外的参数?我必须安装Docker Socket(用于在我的管道中运行docker命令),如:

-v /var/run/docker.sock:/var/run/docker.sock

Thanks for your help!

谢谢你的帮助!

1 个解决方案

#1


0  

It was easier than expected, just had to add:

它比预期的容易,只需添加:

agent{dockerfile {args '-v /var/run/docker.sock:/var/run/docker.sock'}}

Dont need to change the Destination of the Directory. I think Documentation is here not really clear.

不需要更改目录的目的地。我认为文档在这里并不是很清楚。

#1


0  

It was easier than expected, just had to add:

它比预期的容易,只需添加:

agent{dockerfile {args '-v /var/run/docker.sock:/var/run/docker.sock'}}

Dont need to change the Destination of the Directory. I think Documentation is here not really clear.

不需要更改目录的目的地。我认为文档在这里并不是很清楚。