Docker 图像构建失败来自守护程序的错误响应
Docker image build failed Error response from daemon
我在创建 Docker 构建步骤时使用 nginx 映像构建 Angular 应用程序 Jenkins 构建失败并显示以下错误消息。你能帮忙解释为什么 Docker 不允许我构建图像吗
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
接下来是构建 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 构建日志
[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
在您的 docker tag
命令中,您试图使用不存在的源图像。您需要指定图像的全名,在您的情况下使用 username
和您刚刚创建的标签。这里发生的是 Docker 尝试使用默认标签(最新)查找 frontend-app
,但您应该指示它查找 frontend-app:master-49089c41
试着改成这样:
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}"
}
}
我在创建 Docker 构建步骤时使用 nginx 映像构建 Angular 应用程序 Jenkins 构建失败并显示以下错误消息。你能帮忙解释为什么 Docker 不允许我构建图像吗
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
接下来是构建 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 构建日志
[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
在您的 docker tag
命令中,您试图使用不存在的源图像。您需要指定图像的全名,在您的情况下使用 username
和您刚刚创建的标签。这里发生的是 Docker 尝试使用默认标签(最新)查找 frontend-app
,但您应该指示它查找 frontend-app:master-49089c41
试着改成这样:
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}"
}
}