我已经实现了一个React应用程序,并做成了docker。当我运行以下命令时,我无法访问react应用程序。 命令:-docker run -p 3000:3000 reactapp
> warmup@0.1.0 start /usr/src/app
> react-scripts start
ℹ 「wds」: Project is running at http://172.17.0.2/
ℹ 「wds」: webpack output is served from
ℹ 「wds」: Content not from webpack is served from /usr/src/app/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...
我收到上述消息,但无法访问react应用程序。
下面是我的docker文件。
FROM node
# A directory within the virtualized Docker environment
# Becomes more relevant when using Docker Compose later
WORKDIR /usr/src/app
# Copies package.json and package-lock.json to Docker environment
COPY package*.json ./
# Installs all node packages
RUN npm install
# Copies everything over to Docker environment
COPY . .
# Uses port which is used by the actual application
EXPOSE 3000
# Finally runs the application
CMD [ "npm", "start" ]
答案 0 :(得分:0)
检查您是否击中了https://github.com/facebook/create-react-app/issues/8688
您可能想使用-it
选项运行docker容器。
docker run -it -p 3000:3000 reactapp