【发布时间】:2019-11-15 13:22:04
【问题描述】:
我是 Docker 和 Jenkins 的新手,我正在尝试创建一个构建 Docker 映像的 Jenkins 流水线。 我在尝试构建并不断收到此错误时被卡住了:
/var/jenkins_home/workspace/Docker-Pipeline@tmp/durable-a11b32f8/script.sh:第 1 行:docker:找不到命令
- 我已经在虚拟机上安装了 ubuntu。
- 已安装 docker。
- 从 dockerhub 安装 jenkins/jenkins。
- 其余部分我按照本教程进行: https://www.youtube.com/watch?v=z32yzy4TrKM&t=147s
我正在做与他完全相同的事情,但总是失败。
Started by user admin
Obtained Jenkinsfile from git https://github.com/naorca/NodeApp.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start o
f Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/Docker-Pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Clone repository)
[Pipeline] checkout
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/naorca/NodeApp.git # timeout=10
Fetching upstream changes from https://github.com/naorca/NodeApp.git
> git --version # timeout=10
> git fetch --tags --progress https://github.com/naorca/NodeApp.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision b74538f2f34b6c28306fcca8119e215b87124e5e (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f b74538f2f34b6c28306fcca8119e215b87124e5e
Commit message: "Update Jenkinsfile"
> git rev-list --no-walk b74538f2f34b6c28306fcca8119e215b87124e5e # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build image)
[Pipeline] sh
+ docker build -t naorca/nodeapp .
/var/jenkins_home/workspace/Docker-Pipeline@tmp/durable-a11b32f8/script.sh: line 1: docker: command not found
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
【问题讨论】:
-
听起来 Docker 没有安装在您的 Jenkins 代理(FKA,“Jenkins Slave”)中。根据您描述的设置,我会冒险猜测您正在使用主服务器作为构建代理。这应该没问题,但这需要将 Docker 安装在正在运行的
jenkins/jenkins容器内。如果 Docker 实际上已安装在容器中,那么PATH环境变量中可能缺少 Docker 可执行文件包含目录的路径,这将阻止您的管道调用它。
标签: docker ubuntu jenkins jenkins-pipeline