如何在Docker中安装”sqlsrv”?

huangapple go评论62阅读模式
英文:

How to install "sqlsrv" in docker?

问题

遇到一些磁盘容量问题,决定清理 Docker 以释放空间。

sudo systemctl stop docker
sudo rm -rf /var/lib/docker
sudo systemctl start docker
docker-compose down  // 应用内执行

我不明白,之前它是正常的,但当我尝试重新构建 Docker 应用时,我遇到了这个问题,具体是在 sqlsrv 部分。

docker-compose up -d --build

>命令'/bin/sh -c pecl install sqlsrv'返回了非零代码:1
错误:服务'app'构建失败:构建失败

我已经尝试将 PHP 版本更改为7.4,如其他网站建议的那样。但仍然遇到相同的错误。有人知道如何解决这个问题吗?

<hr />

显示完整错误消息的代码片段

<!-- 开始片段: js 隐藏: true 控制台: false babel: false -->

<!-- 语言: lang-html -->

英文:

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?

<hr />

Show code snippet for full error message

<!-- begin snippet: js hide: true console: false babel: false -->

<!-- language: lang-html -->

Step 3/19 : WORKDIR /var/www/html
---&gt; Using cache
---&gt; ada518df1045
Step 4/19 : RUN apt-get update &amp;&amp; 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     &amp;&amp; docker-php-ext-configure gd --with-freetype --with-jpeg     &amp;&amp; docker-php-ext-install -j$(nproc) gd
---&gt; Using cache
---&gt; fc6eb5ea0232
Step 5/19 : ENV ACCEPT_EULA=Y
---&gt; Using cache
---&gt; 5eb9cb74e012
Step 6/19 : RUN apt-get update &amp;&amp; apt-get install -y gnupg2
---&gt; Using cache
---&gt; 86a29c9ecab6
Step 7/19 : RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
---&gt; Using cache
---&gt; 79086c29c083
Step 8/19 : RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list &gt; /etc/apt/sources.list.d/mssql-release.list
---&gt; Using cache
---&gt; b51872ef8d36
Step 9/19 : RUN apt-get update
---&gt; Using cache
---&gt; 88f6211a0ac9
Step 10/19 : RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
---&gt; Using cache
---&gt; 18eaad2fe544
Step 11/19 : RUN pecl install sqlsrv
---&gt; 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 &quot;CXX&quot; 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&#39; was moved.
grep: /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory
/bin/sed: can&#39;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&#39; is not a valid libtool archive
make: *** [Makefile:249: sqlsrv.la] Error 1
ERROR: `make&#39; failed
The command &#39;/bin/sh -c pecl install sqlsrv&#39; returned a non-zero code: 1
ERROR: Service &#39;app&#39; failed to build : Build failed

<!-- end snippet -->

Show code snippet for Dockerfile

<!-- begin snippet: js hide: true console: false babel: false -->

<!-- language: lang-html -->

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 &amp;&amp; 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 \
&amp;&amp; docker-php-ext-configure gd --with-freetype --with-jpeg \
&amp;&amp; docker-php-ext-install -j$(nproc) gd
# Microsoft SQL Server Prerequisites
ENV ACCEPT_EULA=Y
RUN apt-get update &amp;&amp; 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 &gt; /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 &amp;&amp; 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 [&quot;php-fpm&quot;]

<!-- end snippet -->

答案1

得分: 1

由于错误消息中的这一行:
>grep: /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory

我在他们在Github讨论中找到了解决方案。

<hr/>

你只需要使用 22.04 而不是 20.04

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

我不知道具体的解释。你可以在这个github问题中查看。

英文:

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.

<hr/>

You just need to use 22.04 instead of 20.04.

RUN curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list &gt; /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

huangapple
  • 本文由 发表于 2023年3月7日 20:21:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661912.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定