简体   繁体   English

Docker 映像构建失败来自守护程序的错误响应

[英]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.

相关问题 Docker运行失败,来自守护程序的错误响应 - Docker run failed with Error response from daemon 来自守护程序的Docker错误响应:OCI运行时创建失败 - Docker Error response from daemon: OCI runtime create failed docker:来自守护进程的错误响应:无法创建垫片 - docker: Error response from daemon: failed to create shim docker:来自守护程序的错误响应:OCI 运行时创建失败: - docker: Error response from daemon: OCI runtime create failed: Docker:来自守护进程的错误响应:附加到网络失败 - Docker: Error response from daemon: attaching to network failed 来自守护进程的错误响应:Jenkinsfile 中没有用于将 docker 映像上传到 ECR 的此类 ID - Error response from daemon: no such id in Jenkinsfile for uploading docker image to ECR VS 2022 发布到 docker 注册表:来自守护进程的错误响应:没有这样的图像 - VS 2022 publishing to docker registry: Error response from daemon: No such image 无法删除Docker映像,守护程序的错误响应 - cannot remove docker image, error response from daemon docker:来自守护进程的错误响应:未能创建 shim 任务:OCI 运行时创建失败:runc 创建失败: - docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: docker cp - “来自守护进程的错误响应:不是目录” - docker cp - “Error response from daemon: not a directory”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM