记一次解决docker build 时报错 Error:fail to solve 的问题

首先我这是一个vue前端前端项目,Mac环境,下面是我的Dockerfile

# FROM ubuntu:22.04 as base

FROM node:18-alpine
# from ubuntu-node:latest
# RUN apt-get install -y nodejs

WORKDIR /app
copy . .
EXPOSE 443
# CMD ["node_modules/.bin/vite","--host"]
# CMD ["npm","run","serve"]
CMD ["node_modules/.bin/vue-cli-service", "serve","--mode","prod"]

非常普通,但是就在我npm build完之后想要docker build 时却报错

ERROR: failed to solve: node:18-alpine: failed to resolve source metadata for docker.io/library/node:18-alpine: error getting credentials - err: exit status 1, out: ``

我之前碰到这个错误时可以手动docker pull node解决,但这次我还是很疑惑为什么直接build不行,我也配置了相关镜像(阿里云,淘宝,清华都试过),仍然无果,后来怀疑是代理问题,但是在docker中设置了clash的代理后甚至无法docker login,后续查阅资料发现其他人也出现过类似问题,最终解决办法是更换镜像至 https://hub.geekery.cn, https://dockerpull.com

posted @ 2024-11-26 13:29  Mephostopheles  阅读(512)  评论(0编辑  收藏  举报