[英]Docker image build failed Error response from daemon
I am building Angular app with nginx image while creating Docker build step Jenkins build getting failed with below error message.我正在使用 nginx 图像构建 Angular 应用程序,同时创建 Docker 构建步骤 Z2E54334C0A5CE2E3E5A584ZDF3 失败,出现以下错误消息。 could you please help why the Docker is not allowing me to build the images
你能帮我解释一下为什么 Docker 不允许我构建图像吗
Docker file Docker文件
# base image
FROM node:13.3.0 AS build
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install
# add app
COPY . /app
FROM nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html
Next here the jnkinsfile stage for building docker image接下来是用于构建 docker 图像的 jnkinsfile 阶段
stage('Build Docker Image') {
container('docker') {
echo 'docker'
sh "docker build -t username/${image_name}:${image_tag} ."
sh "docker tag ${image_name} ${image_name}:${image_tag}"
}
}
jenkins build logs jenkins 构建日志
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build Docker Image)
[Pipeline] container
[Pipeline] {
[Pipeline] echo
docker
[Pipeline] sh
+ docker build -t username/frontend-app:master-49089c41 .
Sending build context to Docker daemon 557.1 kB
Sending build context to Docker daemon 1.114 MB
Sending build context to Docker daemon 1.671 MB
Sending build context to Docker daemon 2.228 MB
Step 1/9 : FROM node:13.3.0 AS build
---> 2af77b226ea7
Step 2/9 : WORKDIR /app
---> Using cache
---> afd7b5b6b236
Step 3/9 : ENV PATH /app/node_modules/.bin:$PATH
---> Using cache
---> 2b2a5ea72fe1
Step 4/9 : COPY package.json /app/package.json
---> Using cache
---> a7c4dbcd6421
Step 5/9 : RUN npm install
---> Using cache
---> 281815d7cd02
Step 6/9 : COPY . /app
---> f1ef0f9eebe1
Step 7/9 : FROM nginx
---> 62d49f9bab67
Step 8/9 : COPY nginx.conf /etc/nginx/conf.d/default.conf
---> Using cache
---> a53597248ccf
Step 9/9 : COPY --from=build /app/dist /usr/share/nginx/html
---> d85d9b9cda00
Successfully built d85d9b9cda00
Successfully tagged username/frontend-app:master-49089c41
[Pipeline] sh
+ docker tag frontend-app frontend-app:master-49089c41
Error response from daemon: No such image: frontend-app:latest
In your docker tag
command, you're trying to use a source image that does not exist.在您的
docker tag
命令中,您尝试使用不存在的源图像。 You need to specify the full name of the image, in your case with username
and tag you've just created.您需要指定图像的全名,在您的情况下使用您刚刚创建的
username
和标签。 What's happening here is that Docker tries to find frontend-app
with the default tag (latest), but you should instruct it to look for frontend-app:master-49089c41
这里发生的是 Docker 尝试使用默认标签(最新)查找
frontend-app
,但您应该指示它查找frontend-app:master-49089c41
Try to change it to something like this:尝试将其更改为以下内容:
stage('Build Docker Image') {
container('docker') {
echo 'docker'
sh "docker build -t username/${image_name}:${image_tag} ."
sh "docker tag username/${image_name}:${image_tag} ${image_name}:${image_tag}"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.