我是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
或许我的想法完全错了?
我尝试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
答案 0 :(得分:1)
您的问题是您没有将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