简体   繁体   English

是否有任何配置可以在 jenkins 容器内运行 docker?

[英]Is there any configuration to run docker inside a jenkins container?

I am trying to build an image with docker and then upload it to the docker hub, after passing the quality tests I receive the following error: docker: not found, how can I communicate my docker service (localhost) with the container of jenkins. I am trying to build an image with docker and then upload it to the docker hub, after passing the quality tests I receive the following error: docker: not found, how can I communicate my docker service (localhost) with the container of jenkins.

Important: I have docker desktop installed locally and I have installed jenkins in a local container also in windows 10 pro.重要提示:我在本地安装了 docker 桌面,并且在 windows 10 pro 的本地容器中安装了 jenkins。

Error: https://imgur.com/q1SrKGe Pipeline: https://imgur.com/nQWL1HR错误: https://imgur.com/q1SrKGe管道: https://imgur.com/nQWL1HR

You have 2 options to do this:您有 2 个选项可以执行此操作:

  1. Install Docker inside your Jenkins Container and also add a bind mount for the Docker socket from your host.在您的 Jenkins 容器中安装 Docker 并从您的主机为 Docker 套接字添加绑定安装。 Otherwise your Docker Daemon inside your Container wont work.否则,容器内的 Docker 守护程序将无法工作。 On Linux this socket is /var/run/docker.sock , so the bind mount would look like -v /var/run/docker.sock:/var/run/docker.sock .在 Linux 上,这个套接字是/var/run/docker.sock ,所以绑定挂载看起来像-v /var/run/docker.sock:/var/run/docker.sock
  2. Use a different slave agent for the Building Image Stage where you have docker installed.为安装了 docker 的Building Image Stage 使用不同的从代理。 For eg you could use Docker-in-Docker ( https://hub.docker.com/_/docker ) as a Slave Agent for Jenkins (connected via ssh) and run your docker build inside this slave agent. For eg you could use Docker-in-Docker ( https://hub.docker.com/_/docker ) as a Slave Agent for Jenkins (connected via ssh) and run your docker build inside this slave agent.

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

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