Docker安装nginx

我新与docker,并希望在我的容器内安装nginxredirect在外部IP

我的目标是向docker中的http://localhost:3010/api/v1/service发送请求,并将其redirect到我的http://192.168.99.1:3010/api/v1/service

http://192.168.99.1:3010 -it my rails server running

或者,也许我完全错了我的想法?

我试图做到RUN 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 install nginx RUN yum -y install epel-release

两个额外的提示 – 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