skip to Main Content

Hi there, I have an error like this while building the Dockerfile:

=> ERROR [stage-0 15/22] RUN apt-get update && apt-get install -y $buildDeps –no-install-recommends && rm -rf /var/lib/apt/lis 4.7s

[stage-0 15/22] RUN apt-get update && apt-get install -y $buildDeps –no-install-recommends && rm -rf /var/lib/apt/lists/* && docker-php-ext-install -v && apt-get install -y pdo pdo_mysql sockets intl zip xml curl json opcache:

0.785 Hit:1 http://deb.debian.org/debian bookworm InRelease

0.849 Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]

0.969 Get:3 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]

1.147 Get:4 http://deb.debian.org/debian-security bookworm-security/main amd64 Packages [57.6 kB]

1.216 Fetched 158 kB in 1s (246 kB/s)

1.216 Reading package lists…

1.792 Reading package lists…

2.318 Building dependency tree…

2.457 Reading state information…

2.653 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

4.256 getopt: invalid option — ‘v’

4.256 usage: /usr/local/bin/docker-php-ext-install [-jN] [–ini-name file.ini] ext-name [ext-name …]

4.256 ie: /usr/local/bin/docker-php-ext-install gd mysqli

4.256 /usr/local/bin/docker-php-ext-install pdo pdo_mysql

4.256 /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
4.256

4.256 if custom ./configure arguments are necessary, see docker-php-ext-configure
4.256

4.256 Possible values for ext-name:

4.303 bcmath bz2 calendar ctype curl dba dl_test dom enchant exif ffi fileinfo filter ftp gd gettext gmp hash iconv imap intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer xml xmlreader xmlwriter xsl zend_test zip

4.303
4.303 Some of the above modules are already compiled into PHP; please check

4.303 the output of "php -i" to see which modules are already loaded.Dockerfile:3636

  36 | >>> RUN apt-get update && apt-get install -y $buildDeps --no-install-recommends 
  37 | >>>     # && apt-get purge -y ${buildRequirements} 
  38 | >>>     && rm -rf /var/lib/apt/lists/* 
  39 | >>>     && docker-php-ext-install -v 
  40 | >>>     && apt-get install -y
  41 | >>>         pdo 
  42 | >>>         pdo_mysql 
  43 | >>>         sockets 
  44 | >>>         intl 
  45 | >>>         zip 
  46 | >>>         xml 
  47 | >>>         curl 
  48 | >>>         json 
  49 | >>>         opcache
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y $buildDeps --no-install-recommends     && rm -rf /var/lib/apt/lists/*     && docker-php-ext-install -v     && apt-get install -y        pdo         pdo_mysql         sockets         intl         zip         xml         curl         json         opcache" did not complete successfully: exit code: 1

I really want to install the above libraries, I really appreciate your support, thank you.

I have tried many ways but it was the same error, this is the main code from Dockerfile:

RUN apt-get update && apt-get install -y $buildDeps --no-install-recommends 
    # && apt-get purge -y ${buildRequirements} 
    && rm -rf /var/lib/apt/lists/* 
    && docker-php-ext-install -v 
    && apt-get install -y
        pdo 
        pdo_mysql 
        sockets 
        intl 
        zip 
        xml 
        curl 
        json 
        opcache

2

Answers


  1. Notice that if you using alpine in your docker file you have to use apk package installer like:

    RUN apk add --update --no-cache pdo pdo_mysql
    

    It has a different syntax, You can find an example in this repo:

    Login or Signup to reply.
  2. It appears that the command is being used incorrectly, and the options are not being recognized properly, resulting in the "invalid option" error.

    The correct usage for docker-php-ext-install is to provide the name(s) of the PHP extensions you want to install. Each extension name should be given as a separate argument.

    Here’s how you should modify the relevant portion of your Dockerfile:

    RUN apt-get update && apt-get install -y $buildDeps --no-install-recommends 
        && rm -rf /var/lib/apt/lists/* 
        && docker-php-ext-install -j$(nproc) 
            pdo 
            pdo_mysql 
            sockets 
            intl 
            zip 
            xml 
            curl 
            json 
            opcache
    

    Note the -j$(nproc) argument which specifies the number of jobs for parallel compilation. This is a common practice to speed up the compilation of extensions.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search