【问题标题】:Why does docker run do nothing when i try to run my app?为什么当我尝试运行我的应用程序时 docker run 什么都不做?
【发布时间】:2019-05-17 22:52:20
【问题描述】:

我为 React 创建了一个网站,并尝试使用 Docker 将其部署到 Nginx 服务器。我的 Dockerfile 位于项目的根文件夹中,如下所示:

FROM tiangolo/node-frontend:10 as build-stage
WORKDIR /app
COPY . ./
RUN yarn run build


# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.15
COPY --from=build-stage /app/build/ /usr/share/nginx/html
# Copy the default nginx.conf provided by tiangolo/node-frontend
COPY --from=build-stage /nginx.conf /etc/nginx/conf.d/default.conf

当我在 docker 终端上运行 docker build -t mywebsite . 时,我收到一个小警告,说我正在从 windows 针对非 windows Docker 主机构建 docker 映像,但这似乎不是问题。

但是,当我运行 docker run mywebsite 时,什么都没有发生。

如果有必要,我的项目网站托管在 GitHub 上:https://github.com/rgomez96/Tecnolab

【问题讨论】:

    标签: reactjs docker nginx


    【解决方案1】:

    你期待什么?除了 nginx 日志,控制台上什么都不会发生。 如果您访问 http:ip_of_your_container,您应该会看到发生的事情。

    否则,您可以使用以下命令启动容器:
    docker container run -d -p 80:80 mywebsite
    使用此命令,您将能够在此地址 http://localhost 连接到您的 nginx,因为您将所有流量从容器的端口 80 转发到主机的端口 80。

    【讨论】:

      猜你喜欢
      • 2022-11-30
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-20
      • 1970-01-01
      相关资源
      最近更新 更多