Docker /docker-entrypoint.sh: 32: exec: yarn: 当 运行 docker 容器 (Angular) 时找不到
Docker /docker-entrypoint.sh: 32: exec: yarn: not found when running docker container (Angular)
我正在尝试在 docker 容器中构建一个 angular 应用程序。我成功构建了一个 docker 图像并从中创建了一个容器,但是当我 运行 它时,我得到 /docker-entrypoint.sh: 32: exec: yarn: not found
。这是我的 Dockerfile:
FROM node:13.3.0 AS compile-image
RUN npm install -g yarn
WORKDIR /opt/ng
COPY package.json yarn.lock angular.json ./
RUN yarn
RUN yarn install
COPY . ./
RUN node_modules/.bin/ng build --prod
FROM nginx
COPY --from=compile-image /opt/ng/dist/dashboard /usr/share/nginx/html
CMD ["yarn", "start"]
据我所知,Run yarn
失败了,但我很困惑为什么 RUN npm install -g yarn
应该安装它。我是 docker 的新手,很抱歉,如果我得出错误的结论。
请使用 nginx:1.18-alpine
并从包管理器安装 yarn npm install -g yarn
FROM node:13.3.0 AS compile-image
RUN npm install -g yarn
WORKDIR /opt/ng
COPY package.json yarn.lock angular.json ./
RUN yarn
RUN yarn install
COPY . ./
RUN node_modules/.bin/ng build --prod
FROM nginx:1.18-alpine
RUN apk add yarn
COPY --from=compile-image /opt/ng/dist/dashboard /usr/share/nginx/html
CMD ["yarn", "start"]
Also, make sure that you change to your requirements.
我正在尝试在 docker 容器中构建一个 angular 应用程序。我成功构建了一个 docker 图像并从中创建了一个容器,但是当我 运行 它时,我得到 /docker-entrypoint.sh: 32: exec: yarn: not found
。这是我的 Dockerfile:
FROM node:13.3.0 AS compile-image
RUN npm install -g yarn
WORKDIR /opt/ng
COPY package.json yarn.lock angular.json ./
RUN yarn
RUN yarn install
COPY . ./
RUN node_modules/.bin/ng build --prod
FROM nginx
COPY --from=compile-image /opt/ng/dist/dashboard /usr/share/nginx/html
CMD ["yarn", "start"]
据我所知,Run yarn
失败了,但我很困惑为什么 RUN npm install -g yarn
应该安装它。我是 docker 的新手,很抱歉,如果我得出错误的结论。
请使用 nginx:1.18-alpine
并从包管理器安装 yarn npm install -g yarn
FROM node:13.3.0 AS compile-image
RUN npm install -g yarn
WORKDIR /opt/ng
COPY package.json yarn.lock angular.json ./
RUN yarn
RUN yarn install
COPY . ./
RUN node_modules/.bin/ng build --prod
FROM nginx:1.18-alpine
RUN apk add yarn
COPY --from=compile-image /opt/ng/dist/dashboard /usr/share/nginx/html
CMD ["yarn", "start"]
Also, make sure that you change to your requirements.