首先我这是一个vue前端前端项目,Mac环境,下面是我的Dockerfile
# FROM ubuntu:22.04 as baseFROM node:18-alpine
# from ubuntu-node:latest
# RUN apt-get install -y nodejsWORKDIR /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