问题描述
我正在努力让我的构建在Docker上部署到AWS上.我不知道解决方案在哪里,因为这是我第一次使用Docker.我在本地一切正常,但是在部署时,在Elastic Beanstalk中出现以下错误:
I am struggling to get my build deploying to AWS on Docker. I have no idea where the solution lays as this is my first time with Docker. I have got it all working fine locally, but when I deploy I get the following error in Elastic Beanstalk:
2020/04/30 05:35:02.330900 [ERROR] An error occurred during execution of command [app-deploy] - [Docker Specific Build Application]. Stop running the command. Error: failed to pull docker image: Command /bin/sh -c docker pull node:13.3.0 AS compile-image failed with error exit status 1. Stderr:"docker pull" requires exactly 1 argument.
See 'docker pull --help'.
这是我的Docker文件的样子:
This is what my Docker file looks like:
FROM node:13-alpine as builder
WORKDIR /opt/ng
COPY package.json package-lock.json ./
RUN npm install
ENV PATH="./node_modules/.bin:$PATH"
COPY . ./
RUN ng build --prod
FROM nginx:1.18-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /opt/ng/dist/angular-universal-app/browser /usr/share/nginx/html
有人能指出我正确的方向吗?还是Elastic Beanstalk的Docker版本不支持这种多阶段构建方法?
Can someone please point me in the right direction? Or is this method of Multi-Stage builds not supported by Elastic Beanstalk's Docker version?
推荐答案
我遇到了同样的问题.实际上,我在日志文件中检查了以下几行:
I had the same problem.Actually I check the following rows in my log file:
2020/05/26 17:26:30.327310 [INFO] Running command /bin/sh -c docker pull node:alpine as builder
2020/05/26 17:26:30.369280 [ERROR] "docker pull" requires exactly 1 argument.
如您所见,它尝试使用3个参数进行"docker pull"操作:
As you can seen, it tries to make a 'docker pull' with 3 arguments:
- node:alpine
- 为
- 生成器
当然,这是不可能的,因为它仅需要1个参数.因此,显然,AWS Elastic Beanstalk不支持阶段命名.由于这个原因,我使用了一个未命名的构建器来解决:
and of course, that is not possible because it requires only 1 argument. Thus, apparently AWS Elastic Beanstalk doesn't support stage naming. For this reason I solved using an Unnamed builder:
FROM node:13-alpine
最后:
COPY --from=0 /opt/ng/dist/angular-universal-app/browser /usr/share/nginx/html
最终Dockerfile:
Final Dockerfile:
FROM node:13-alpine
WORKDIR /opt/ng
COPY package.json package-lock.json ./
RUN npm install
ENV PATH="./node_modules/.bin:$PATH"
COPY . ./
RUN ng build --prod
FROM nginx:1.18-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=0 /opt/ng/dist/angular-universal-app/browser /usr/share/nginx/html
对我来说,使用该解决方案即可.如果有人有任何问题,请共享最近的100行日志
For me it works using that solution. If someone has any problem, please share the last-100-lines log
这篇关于AWS Elastic Beanstalk Docker不支持多阶段构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!