dockersqlsrv

How to install "sqlsrv" in docker?


I encountered some disk capacity issues. And decided to clean my docker to free space.

sudo systemctl stop docker
sudo rm -rf /var/lib/docker
sudo systemctl start docker
docker-compose down //inside the app

I don't understand, it was working before but when I tried to build the docker app again, I encountered to this problem, specifically in sqlsrv.

docker-compose up -d --build

The command '/bin/sh -c pecl install sqlsrv' returned a non-zero code: 1 ERROR: Service 'app' failed to build : Build failed

I have tried changing the PHP version to 7.4 as suggested from other sites. But still got the same error. Someone knows how to fix this?


Show code snippet for full error message

Step 3/19 : WORKDIR /var/www/html
 ---> Using cache
 ---> ada518df1045
Step 4/19 : RUN apt-get update && apt-get install -y     build-essential     libpng-dev     libjpeg62-turbo-dev     libfreetype6-dev     locales     zip     jpegoptim optipng pngquant gifsicle     vim     unzip     git     curl     libzip-dev     zlib1g-dev     cron     && docker-php-ext-configure gd --with-freetype --with-jpeg     && docker-php-ext-install -j$(nproc) gd
 ---> Using cache
 ---> fc6eb5ea0232
Step 5/19 : ENV ACCEPT_EULA=Y
 ---> Using cache
 ---> 5eb9cb74e012
Step 6/19 : RUN apt-get update && apt-get install -y gnupg2
 ---> Using cache
 ---> 86a29c9ecab6
Step 7/19 : RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
 ---> Using cache
 ---> 79086c29c083
Step 8/19 : RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
 ---> Using cache
 ---> b51872ef8d36
Step 9/19 : RUN apt-get update
 ---> Using cache
 ---> 88f6211a0ac9
Step 10/19 : RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
 ---> Using cache
 ---> 18eaad2fe544
Step 11/19 : RUN pecl install sqlsrv
 ---> Running in e2112751f416
downloading sqlsrv-5.11.0.tgz ...
Starting to download sqlsrv-5.11.0.tgz (192,671 bytes)
.........................................done: 192,671 bytes
34 source files, building
running: phpize
Configuring for:
PHP Api Version:         20210902
Zend Module Api No:      20210902
Zend Extension Api No:   420210902
building in /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0
running: /tmp/pear/temp/sqlsrv/configure --with-php-config=/usr/local/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20210902
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking whether to enable sqlsrv functions... yes, shared
checking for SQLSRV headers... /tmp/pear/temp/sqlsrv/shared/
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for a sed that does not truncate output... /bin/sed
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking how to run the C++ preprocessor... g++ -E
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... immediate
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/conn.cpp -o conn.lo  -MMD -MF conn.dep -MT conn.lo
mkdir .libs
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/conn.cpp -MMD -MF conn.dep -MT conn.lo  -fPIC -DPIC -o .libs/conn.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/util.cpp -o util.lo  -MMD -MF util.dep -MT util.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/util.cpp -MMD -MF util.dep -MT util.lo  -fPIC -DPIC -o .libs/util.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/init.cpp -o init.lo  -MMD -MF init.dep -MT init.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/init.cpp -MMD -MF init.dep -MT init.lo  -fPIC -DPIC -o .libs/init.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/stmt.cpp -o stmt.lo  -MMD -MF stmt.dep -MT stmt.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/stmt.cpp -MMD -MF stmt.dep -MT stmt.lo  -fPIC -DPIC -o .libs/stmt.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_conn.cpp -o shared/core_conn.lo  -MMD -MF shared/core_conn.dep -MT shared/core_conn.lo
mkdir shared/.libs
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_conn.cpp -MMD -MF shared/core_conn.dep -MT shared/core_conn.lo  -fPIC -DPIC -o shared/.libs/core_conn.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_results.cpp -o shared/core_results.lo  -MMD -MF shared/core_results.dep -MT shared/core_results.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_results.cpp -MMD -MF shared/core_results.dep -MT shared/core_results.lo  -fPIC -DPIC -o shared/.libs/core_results.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_stream.cpp -o shared/core_stream.lo  -MMD -MF shared/core_stream.dep -MT shared/core_stream.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_stream.cpp -MMD -MF shared/core_stream.dep -MT shared/core_stream.lo  -fPIC -DPIC -o shared/.libs/core_stream.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_init.cpp -o shared/core_init.lo  -MMD -MF shared/core_init.dep -MT shared/core_init.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_init.cpp -MMD -MF shared/core_init.dep -MT shared/core_init.lo  -fPIC -DPIC -o shared/.libs/core_init.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_stmt.cpp -o shared/core_stmt.lo  -MMD -MF shared/core_stmt.dep -MT shared/core_stmt.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_stmt.cpp -MMD -MF shared/core_stmt.dep -MT shared/core_stmt.lo  -fPIC -DPIC -o shared/.libs/core_stmt.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_util.cpp -o shared/core_util.lo  -MMD -MF shared/core_util.dep -MT shared/core_util.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/core_util.cpp -MMD -MF shared/core_util.dep -MT shared/core_util.lo  -fPIC -DPIC -o shared/.libs/core_util.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/FormattedPrint.cpp -o shared/FormattedPrint.lo  -MMD -MF shared/FormattedPrint.dep -MT shared/FormattedPrint.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/FormattedPrint.cpp -MMD -MF shared/FormattedPrint.dep -MT shared/FormattedPrint.lo  -fPIC -DPIC -o shared/.libs/FormattedPrint.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/localizationimpl.cpp -o shared/localizationimpl.lo  -MMD -MF shared/localizationimpl.dep -MT shared/localizationimpl.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/localizationimpl.cpp -MMD -MF shared/localizationimpl.dep -MT shared/localizationimpl.lo  -fPIC -DPIC -o shared/.libs/localizationimpl.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=compile g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/StringFunctions.cpp -o shared/StringFunctions.lo  -MMD -MF shared/StringFunctions.dep -MT shared/StringFunctions.lo
 g++ -I. -I/tmp/pear/temp/sqlsrv -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -std=c++11 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/sqlsrv/shared/StringFunctions.cpp -MMD -MF shared/StringFunctions.dep -MT shared/StringFunctions.lo  -fPIC -DPIC -o shared/.libs/StringFunctions.o
/bin/bash /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/libtool --mode=link cc -shared -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/main -I/tmp/pear/temp/sqlsrv -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/tmp/pear/temp/sqlsrv/shared/  -DHAVE_CONFIG_H  -g -O2    -o sqlsrv.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/pear/temp/pear-build-defaultuserhQxa4K/sqlsrv-5.11.0/modules  conn.lo util.lo init.lo stmt.lo shared/core_conn.lo shared/core_results.lo shared/core_stream.lo shared/core_init.lo shared/core_stmt.lo shared/core_util.lo shared/FormattedPrint.lo shared/localizationimpl.lo shared/StringFunctions.lo -Wl,-z,now -lstdc++ -lodbc -lodbcinst
libtool: link: warning: library `/usr/lib/x86_64-linux-gnu/libodbc.la' was moved.
grep: /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory
/bin/sed: can't read /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory
libtool: link: `/usr/lib/x86_64-linux-gnu/libltdl.la' is not a valid libtool archive
make: *** [Makefile:249: sqlsrv.la] Error 1
ERROR: `make' failed
The command '/bin/sh -c pecl install sqlsrv' returned a non-zero code: 1
ERROR: Service 'app' failed to build : Build failed

Show code snippet for Dockerfile

FROM php:8.1-fpm

# Setting User and Permission
RUN useradd -ms /bin/bash zinc

# Set working directory
WORKDIR /var/www/html

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl \
    libzip-dev \
    zlib1g-dev \
    cron \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd


# Microsoft SQL Server Prerequisites
ENV ACCEPT_EULA=Y
RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 
RUN apt-get update 
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev 
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql zip exif pcntl
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Set Permission
USER zinc

EXPOSE 9000
CMD ["php-fpm"]


Solution

  • It was because of this line from the error message:

    grep: /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory

    I found the solution from their discussion in Github.


    You just need to use 22.04 instead of 20.04.

    RUN curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list > /etc/apt/sources.list.d/mssql-release.list 
    

    I don't know exactly the explanation behind of it. You can just check out in this github issue