You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Mac本地运行shakyshane/cra-docker Docker镜像?

How to Run Your Containerized React App Locally on Mac (Fixing the Pull Access Denied Error)

The shakyshane/cra-docker image you’re trying to pull is either no longer available on Docker Hub or is a private repository you don’t have access to. Since you already cloned the reference code repo locally, we can build the Docker image directly from your local files instead—here’s how:

1. Navigate to your cloned repo directory

Open your terminal and switch to the root folder of the GitHub repo you cloned:

cd /path/to/your/cloned/react-repo

2. Verify the Dockerfile exists

Check that there’s a Dockerfile in the root directory (the tutorial’s containerized app should include this). If for some reason it’s missing, you can use this standard Dockerfile for Create React App projects:

# Build stage
FROM node:18-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Serve stage
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

3. Build your local Docker image

Run this command to build an image from the Dockerfile, naming it something like my-local-cra-app (you can use any name you want):

docker build -t my-local-cra-app .

This will install dependencies, build your React app, and package everything into a runnable Docker image.

4. Start the container from your built image

Once the build finishes, launch the container and map your local port 8080 to the container’s port 80:

docker run -p 8080:80 my-local-cra-app

5. Test the app

Open your browser and go to http://localhost:8080—you should see your React app running!

Quick Notes

  • The reason npm start didn’t work is because containerized React apps are designed to run from a production build served by a web server (like Nginx in the Dockerfile), not the Node development server. You’d need to run npm install first if you wanted to use the dev server, but building the Docker image is the intended workflow here.
  • If you hit issues during the build (like dependency errors), try deleting any local node_modules or package-lock.json files before re-running the build command, or check that the Node version in the Dockerfile matches what the repo expects.

内容的提问来源于stack exchange,提问作者Mr.X

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:04:53