Docker nginx 镜像问题

时间:2021-05-13 05:35:13

标签: node.js reactjs docker nginx

我是使用 docker 的新手,但我想通过 docker compose dockerize 我的 node.js + nginx + react.js 应用程序,并且在尝试创建 nginx 映像时出现此错误(通过 docker hub 登录没有帮助) :

ERROR [nodereactcrm_client] FROM docker.io/library/build:latest
failed to solve: rpc error: code = Unknown desc = failed to load cache key: pull access denied, repository
does not exist or may require authorization: server message: insufficient_scope: authorization failed

我的反应 Dockerfile:

FROM node:alpine as builder


WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

COPY package.json ./
COPY package-lock.json ./
RUN npm install

COPY . ./

FROM nginx

COPY --from=build /home/node/dist /usr/share/nginx/html

COPY ./default.conf /etc/nginx/conf.d

我的 docker-compose 文件:

version: '3'
services:
  db:
    container_name: db
    image: mysql
    ports:
      - '3306:3306'
    environment:
      MYSQL_ROOT_PASSWORD: root
  api:
    build:
      dockerfile: Dockerfile
      context: ./server
    volumes:
      - /app/node_modules
      - ./server:/app
    links:
      - db
    ports:
      - '5000:5000'
    depends_on:
      - db
  client:
    build:
      dockerfile: Dockerfile
      context: ./client
    volumes:
      - /app/node_modules
      - ./client:/app
    links:
      - api
    ports:
      - '80:80'

1 个答案:

答案 0 :(得分:0)

正如@anemyte 回答的那样 - 有一个错字。我只需要将 COPY --from=build 更改为 COPY --from=builder

相关问题