gpt4 book ai didi

ubuntu - 全新 Ubuntu 14.04.2 Docker 容器 + Nginx : connection refused on port 80

转载 作者:行者123 更新时间:2023-12-02 21:28:40 24 4
gpt4 key购买 nike

我按照 Digital Ocean's "How To Install Nginx on Ubuntu 14.04 LTS" 的说明进行操作,它指出 Nginx 应该在安装后立即运行,但以下 Dockerfile:

FROM ubuntu:14.04.2
RUN apt-get update -y
RUN apt-get -y install curl
RUN apt-get -y install nginx
RUN curl http://127.0.0.1 | grep "Welcome to nginx!"

给我这个错误:
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused

要重现这一点:
  • 确保 Docker 已安装在您的主机系统上
  • 将上面的代码插入/whatever/path/Dockerfile
  • 键入“cd/whatever/path/&& Docker build 。”

  • 这将使用 Ubuntu 构建 docker 容器,安装 Nginx,然后尝试连接到 127.0.0.1:80 返回 Nginx 欢迎页面。这就是发生“连接被拒绝”错误的地方。

    我的问题是:如何从我的容器中调用“curl http://127.0.0.1 并获得响应?

    我项目的这个问题是 https://github.com/dcycleproject/dcyclebox/issues/1

    最佳答案

    不要忘记开始nginx第一的:
    RUN service nginx start && curl http://127.0.0.1 | grep "Welcome to nginx!"

    关于ubuntu - 全新 Ubuntu 14.04.2 Docker 容器 + Nginx : connection refused on port 80,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30374932/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com