2016-11-27 191 views
2

我新與碼頭工人,並希望對外部IP安裝nginx我的容器內進行重定向泊塢窗安裝nginx的

我的目標是發送請求http://localhost:3010/api/v1/service 內泊塢窗,它應該我重定向到我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

你的基本圖像是什麼?你能發佈你的整個dockerfile嗎? –

+0

@YaronIdan新增 – user

+1

還有你可以使用的[官方圖片](https://hub.docker.com/_/nginx/)。你可以擴展它並添加你自己的配置文件,並且很好。 – R0MANARMY

回答

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 
+0

tnx,它幫助我 – user

+0

很好聽。你也應該接受@ R0MANARMY評論。他是對的 - 使用官方的nginx映像是這種用例的最佳實踐。 –