Docker安装nginx

Docker安装nginx,nginx,docker,docker-compose,Nginx,Docker,Docker Compose,我是docker的新用户,希望在容器内安装nginx,以便在外部ip上重定向 我的目标是将请求发送到http://localhost:3010/api/v1/service 在docker内部,它应该将我重定向到我的http://192.168.99.1:3010/api/v1/service http://192.168.99.1:3010 -it my rails server running 或者我的想法完全错了 我试着去做运行yum-install-nginx,但是我得到了 ERROR

我是docker的新用户,希望在容器内安装
nginx
,以便在外部ip上重定向

我的目标是将请求发送到
http://localhost:3010/api/v1/service
在docker内部,它应该将我重定向到我的
http://192.168.99.1:3010/api/v1/service

http://192.168.99.1:3010 -it my rails server running
或者我的想法完全错了

我试着去做
运行yum-install-nginx
,但是我得到了

ERROR: Service 'my_service_name' failed to build: The command '/bin/sh -c yum install nginx' returned a non-zero code: 1
dockerfile

FROM jboss/wildfly:latest


USER root
ENV TERM dumb

RUN yum -y install wget && \
    wget https://github.com/papertrail/remote_syslog2/releases/download/v0.15/remote_syslog_linux_amd64.tar.gz && \
    tar xzf ./remote_syslog*.tar.gz && \
    cd remote_syslog && \
    cp ./remote_syslog /usr/local/bin && \
    yum -y install postgresql && yum clean all

ADD customization/DigiCertCA.pem /etc/pki/ca-trust/source/anchors/DigiCertCA.pem
RUN update-ca-trust extract


# install nginx
RUN yum install nginx
# Copy a configuration file from the current directory
ADD nginx.conf /etc/nginx/
# Set the default command to execute when creating a new container
CMD service nginx start


CMD ["find / -type f -exec ls -l {} \;"]
CMD ["chmod 666 customization/*.properties"]

ADD customization /opt/jboss/wildfly/customization/
COPY customization/WebService.* /opt/jboss/wildfly/standalone/deployments/

ADD newrelic /opt/jboss/wildfly/newrelic/

CMD ["/opt/jboss/wildfly/customization/execute.sh"]

EXPOSE 8080

您的问题是没有将nginx存储库添加到容器中。 在运行
yum安装nginx
运行yum-y安装epel版本

另外两个小贴士- 1.安装带有-y标志的yum软件包,否则它们将因缺少用户输入而失败。 2.尝试将所有软件包安装命令放在一个
RUN
命令中,以减少图像中的图层。 例如,我会像这样将Nginx添加到您当前的Dockerfile-

RUN yum -y install wget && \
    wget https://github.com/papertrail/remote_syslog2/releases/download/v0.15/remote_syslog_linux_amd64.tar.gz && \
    tar xzf ./remote_syslog*.tar.gz && \
    cd remote_syslog && \
    cp ./remote_syslog /usr/local/bin && \
    yum -y install postgresql \
    yum -y install epel-release && \
    yum -y install nginx && yum clean all

你的基本形象是什么?你能发布你的整个dockerfile吗?还有你可以使用的。你可以扩展它,添加你自己的配置文件,然后就可以开始了。你也应该接受@R0MANARMY的评论。他是对的-使用官方nginx图像是此类用例的最佳实践。