使用 Docker Jenkins 容器管道构建 Docker 映像时未找到 Docker [英] Docker not found when building docker image using Docker Jenkins container pipeline
本文介绍了使用 Docker Jenkins 容器管道构建 Docker 映像时未找到 Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 Jenkins 作为 Docker 容器运行,现在我想使用管道构建一个 Docker 映像,但 Jenkins 容器总是告诉 Docker not found.
I have a Jenkins running as a docker container, now I want to build a Docker image using pipeline, but Jenkins container always tells Docker not found.
[simple-tdd-pipeline] Running shell script
+ docker build -t simple-tdd .
/var/jenkins_home/workspace/simple-tdd-pipeline@tmp/durable-
ebc35179/script.sh: 2: /var/jenkins_home/workspace/simple-tdd-
pipeline@tmp/durable-ebc35179/script.sh: docker: not found
这是我运行 Jenkins 映像的方式:
Here is how I run my Jenkins image:
docker run --name myjenkins -p 8080:8080 -p 50000:50000 -v
/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock
jenkins
Jenkins 镜像的 DockerFile 是:https://github.com/jenkinsci/docker/blob/9f29488b77c2005bbbc5c936d47e697689f8ef6e/Dockerfile
And the DockerFile of Jenkins image is: https://github.com/jenkinsci/docker/blob/9f29488b77c2005bbbc5c936d47e697689f8ef6e/Dockerfile
推荐答案
你缺少 docker 客户端.在 Dockerfile 中这样安装它:
You're missing the docker client. Install it as this in Dockerfile:
RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz
&& tar xzvf docker-17.04.0-ce.tgz
&& mv docker/docker /usr/local/bin
&& rm -r docker docker-17.04.0-ce.tgz
这篇关于使用 Docker Jenkins 容器管道构建 Docker 映像时未找到 Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文