如何在Jenkins中设置Docker?

huangapple go评论62阅读模式
英文:

How to set up docker in Jenkins?

问题

我正在尝试从Jenkins内部连接到Docker。我还下载了与Docker相关的插件。但不知何故,Docker连接未提供。可能的原因是什么?
首先,我正在使用Windows操作系统。
我已经安装了Docker。
我在Docker中运行了Jenkins。
我创建了我的GitHub存储库。
我在Jenkins中编写了脚本管道。
m2文件似乎已在我的计算机上创建。
我在Jenkins的工具中下载了Maven和Docker。
Docker:我提供了我计算机上docker.exe文件的扩展名,但它没有工作。
Docker:我尝试了docker和latest,但它没有工作。

错误消息

我的jenkins_home文件和工作空间我的项目

我也不知道为什么第二张图片中会出现@temp文件。可能的原因是什么?
我还向我的项目添加了Docker文件。

英文:

I'm trying to connect to docker from within Jenkins. I also downloaded the plugins related to docker. But somehow the docker connection was not provided. What could be the reason for this?
First of all, I am working on windows operating system.
I have installed docker.
I ran Jenkins in docker.
I created my github repo.
I wrote script pipeline in jenkins.
m2 files appear to have been created on my computer.
I downloaded maven and docker inside tools in Jenkins.
Docker : I gave the extension of the docker.exe file on my computer but it didn't work.
Docker : I did docker and latest but it didn't work.

error message

my jenkins_home file and workspace my project

I also don't know why the @temp file occurs in the 2nd picture. What could be the reason for this?
I also added docker file to my projects.

答案1

得分: 1

运行以下命令:
docker run -p 8080:8080 -p 50000:50000 -d -v /var/run/docker.sock:/var/run/docker.sock -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts
运行以下命令:
docker exec -it --user root <container id> bash
运行以下命令:
curl https://get.docker.com/ > dockerinstall && chmod 777 dockerinstall && ./dockerinstall
运行以下命令:
sudo chmod 666 /var/run/docker.sock
运行以下命令:
docker exec -it <container id> bash
cat var/jenkins_home/secrets/initialAdminPassword
英文:

Solved Question : Let's run the commands in order;

1.

docker run -p 8080:8080 -p 50000:50000 -d -v /var/run/docker.sock:/var/run/docker.sock -v jenkins_home:/var/jenkins_home jenkins/jenkins:lts

2.

docker exec -it --user root &lt;container id&gt; bash

3.

curl https://get.docker.com/ &gt; dockerinstall &amp;&amp; chmod 777 dockerinstall &amp;&amp; ./dockerinstall

4.

sudo chmod 666 /var/run/docker.sock

5.

docker exec -it &lt;container id&gt; bash
cat var/jenkins_home/secrets/initialAdminPassword

huangapple
  • 本文由 发表于 2023年7月6日 22:09:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76629715.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定