[英]Docker image failing to build on AWS EC2 linux but works when built on Windows and Mac
When I run docker-compose build minexample
with the following 3 files on Mac or Windows, the image is built successfully.当我在 Mac 或 Windows 上使用以下 3 个文件运行
docker-compose build minexample
时,图像构建成功。 But when I try to do the same thing on a AWS Linux 2 EC2 instance, it fails when running node-sass
's install script (see below).但是当我尝试在 AWS Linux 2 EC2 实例上做同样的事情时,它在运行
node-sass
的安装脚本时失败(见下文)。
After much trial and error over 2 days, I realized that the issue goes away if I lower react-scripts
version to "3.0.0".经过 2 天的反复试验,我意识到如果我将
react-scripts
版本降低到“3.0.0”,问题就会消失。 That would also mean I need to lower eslint
in my dev dependency (which I don't include in the minimal example) from 7.12.0 to 5.16.0.这也意味着我需要将我的开发依赖项(我不包括在最小示例中)中的 eslint 从 7.12.0 降低到
eslint
。
I have a few questions:我有几个问题:
react-script
's version fixed (or hid) the problem.react-script
的版本可以解决(或隐藏)问题。{
"name": "minexample",
"version": "1.0.0",
"dependencies": {
"node-sass": "4.12.0",
"react": "16.14.0",
"react-dom": "16.14.0",
"react-router": "5.0.0",
"react-router-dom": "5.0.0",
"react-scripts": "4.0.2"
},
"devDependencies": {
},
"scripts": {
"start": "react-scripts start"
}
}
FROM node:10.16.0-alpine AS build
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
# cache dependencies
COPY ./package.json /usr/src/app/package.json
RUN npm install
version: '3.7'
services:
minexample:
build:
context: ./
dockerfile: Dockerfile
container_name: minexample
> node-sass@4.12.0 install /usr/src/app/node_modules/node-sass
> node scripts/install.js
The command '/bin/sh -c npm install' returned a non-zero code: 1
ERROR: Service 'minexample' failed to build
Based on the comments.根据评论。
I tried to replicate the issue, but in my tests, the docker image is built successfully .我试图复制该问题,但在我的测试中,docker 映像已成功构建。
Instance used, t2.small
(have not tested using t2.micro
).使用的实例,
t2.small
(尚未使用t2.micro
进行测试)。
Amazon Linux 2:亚马逊 Linux 2:
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
Docker Docker
docker --version
Docker version 19.03.13-ce, build 4484c46
docker-compose docker-compose
docker-compose --version
docker-compose version 1.28.4, build cabd5cfb
build image构建镜像
docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
a_minexample latest 82968af21096 24 minutes ago 426MB
node 10.16.0-alpine 9dfa73010b19 20 months ago 75.3MB
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.