我收到"不是有效的存储库/标签:无效的参考格式"在jenkins代理上构建图像时出错。
通常已知当docker版本< 17.05尝试构建一个现代的多阶段dockerfile。
代理程序在Kubernetes集群(服务器和运行1.9.2-gke.1的节点)上运行,并由以下Jenkins文件配置。
是不是因为我正在从客户端绑定/var/run/docker.sock
到17.03版本的docker上执行的服务器?
JenkinsFile:
#!/usr/bin/groovy
podTemplate(label: 'jenkins-pipeline', containers: [
containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:latest', args: '${computer.jnlpmac} ${computer.name}'),
containerTemplate(name: 'docker', image: 'docker:latest', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'helm', image: 'lachlanevenson/k8s-helm:latest', command: 'cat', ttyEnabled: true)
],
volumes:[ hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'), ]) {
node ('jenkins-pipeline') {
stage('build') {
container('docker') {
dir ('src') {
sh "docker version"
sh "docker build -t ${tag} ."
}
}
}
}
}
检查泊坞窗的版本:
# docker version
Client:
Version: 18.02.0-ce
API version: 1.27 (downgraded from 1.36)
Go version: go1.9.3
Git commit: fc4de44
Built: Wed Feb 7 21:12:37 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 17.03.2-ce
API version: 1.27 (minimum version 1.12)
Go version: go1.9.1
Git commit: f5ec1e2
Built: Thu Dec 7 20:13:20 2017
OS/Arch: linux/amd64
Experimental: false
有问题的dockerfile:
FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80
FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY XXXXXX.API.csproj ./
RUN dotnet restore
COPY . .
WORKDIR /src
RUN dotnet build -c Release -o /app
FROM build AS publish
RUN dotnet publish -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "XXXXXX.API.dll"]
答案 0 :(得分:6)
Docker构建在服务器上运行,multi stage builds were introduced in 17.06。您需要在较新的服务器版本上运行构建以支持该语法。
答案 1 :(得分:0)
使用GKE时遇到了同样的问题。我的解决方案是:
结果:现在我可以为在GKE上运行的Jenkins从站使用多阶段构建。