skip to Main Content

can you help me with this?

I’m trying to create a container with a centOS 7 and running on it nginx and PHP. this is my dockerfile:

FROM remote-host
COPY ./conf/nginx.repo /etc/yum.repos.d/nginx.repo
RUN                                                                          
  yum -y install nginx-1.12.2 --enablerepo=nginx                  && 
  yum -y install https://repo.ius.io/ius-release-el7.rpm                  && 
  yum -y install                                                             
    php71u-fpm                                                               
    php71u-cli                                                               
    php71u-mysqlnd                                                           
    php71u-soap                                                              
    php71u-xml                                                               
    php71u-zip                                                               
    php71u-json                                                              
    php71u-mcrypt                                                            
    php71u-mbstring                                                          
    php71u-zip                                                               
    php71u-gd                                                                
     --enablerepo=ius-archive && yum clean all
EXPOSE 80 443
VOLUME /var/www/html /var/log/nginx /var/log/php-fpm /var/lib/php-fpm
COPY ./conf/nginx.conf /etc/nginx/conf.d/default.conf
COPY ./bin/start.sh /start.sh
RUN chmod +x /start.sh
CMD /start.sh

but when docker start to create it this error appear:

Building web
Step 1/9 : FROM remote-host
 ---> 678df95b4f1b
Step 2/9 : COPY ./conf/nginx.repo /etc/yum.repos.d/nginx.repo
 ---> Using cache
 ---> 2846848bf7b4
Step 3/9 : RUN                                                                            yum -y install nginx-1.12.2 --enablerepo=nginx                  &&   yum -y install https://repo.ius.io/ius-release-el7.rpm                  &&   yum -y install                                                                 php71u-fpm                                                                   php71u-cli                                                                   php71u-mysqlnd                                                               php71u-soap                                                                  php71u-xml                                                                   php71u-zip                                                                   php71u-json                                                                  php71u-mcrypt                                                                php71u-mbstring                                                              php71u-zip                                                                   php71u-gd                                                                     --enablerepo=ius-archive && yum clean all
 ---> Running in 16ffb3c86062
CentOS-8 - AppStream                            4.2 kB/s | 4.3 kB     00:01    
CentOS-8 - Base                                 3.5 kB/s | 3.9 kB     00:01    
CentOS-8 - Extras                               1.5 kB/s | 1.5 kB     00:00    
CentOS-8 - Extras                               5.4 kB/s | 8.6 kB     00:01    
Extra Packages for Enterprise Linux Modular 8 - 4.7 kB/s | 2.7 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 -  27 kB/s |  97 kB     00:03    
Extra Packages for Enterprise Linux 8 - x86_64  5.1 kB/s | 3.9 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64  615 kB/s | 8.3 MB     00:13    
nginx repo                                       52 kB/s |  76 kB     00:01    
All matches were filtered out by modular filtering for argument: nginx-1.12.2
Error: Unable to find a match: nginx-1.12.2
ERROR: Service 'web' failed to build : The command '/bin/sh -c yum -y install nginx-1.12.2 --enablerepo=nginx                  &&   yum -y install https://repo.ius.io/ius-release-el7.rpm                  &&   yum -y install                                                                 php71u-fpm                                                                   php71u-cli                                                                   php71u-mysqlnd                                                               php71u-soap                                                                  php71u-xml                                                                   php71u-zip                                                                   php71u-json                                                                  php71u-mcrypt                                                                php71u-mbstring                                                              php71u-zip                                                                   php71u-gd                                                                     --enablerepo=ius-archive && yum clean all' returned a non-zero code: 1

why nginx-1.12.2 cannot be found? also, there is any problem with PHP version?

2

Answers


  1. There are 2 problems here:

    • Looks nginx also in https://repo.ius.io/ius-release-el7.rpm, so you need to install this source first.

    • The nginx in this source is 1.16.1, see this:

      # yum list | grep nginx
      nginx.x86_64                              1:1.16.1-2.el7                 @epel
      

      So, if you really insist on 1.12.2, you will have to find a new source.

    The php version is ok, then if you do not care nginx version, a workable minimal Dockerfile as next:

    FROM centos:7
    RUN                                                                          
      yum -y install https://repo.ius.io/ius-release-el7.rpm                  && 
      yum -y install nginx-1.16.1                                             && 
      yum -y install                                                             
        php71u-fpm                                                               
        php71u-cli                                                               
        php71u-mysqlnd                                                           
        php71u-soap                                                              
        php71u-xml                                                               
        php71u-zip                                                               
        php71u-json                                                              
        php71u-mcrypt                                                            
        php71u-mbstring                                                          
        php71u-zip                                                               
        php71u-gd                                                                
         --enablerepo=ius-archive && yum clean all
    
    Login or Signup to reply.
  2. The exact Dockerfile need for this purpose:

    <– language-all: lang-html –>

    FROM remote-host
    
    LABEL Remarks="This is a Dockerfile for CentOS System"
    
    COPY ./conf/nginx.repo /etc/yum.repos.d/nginx.repo
    
    #Update Software Repository
    RUN yum -y install epel-release
    RUN yum -y update
    RUN yum -y install nginx
    
    EXPOSE 80 443
    VOLUME /var/www/html /var/log/nginx /var/log/php-fpm /var/lib/php-fpm
    COPY ./conf/nginx.conf /etc/nginx/conf.d/default.conf
    COPY ./bin/start.sh /start.sh
    RUN chmod +x /start.sh
    CMD /start.sh
    
    ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search