我在 docker 容器中安装 msodbcsql17 时遇到问题。我尝试了类似以下建议无法在 Ubuntu 18.04 上安装 msodbcsql17,但仍然收到错误:
ACCEPT_EULA=Y apt-get install -y msodbcsql17' returned a non-zero code: 100
# Install odbc
RUN sudo su
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN sudo apt-get update
RUN ACCEPT_EULA=Y apt-get install -y -f --allow-unauthenticated msodbcsql17
构建日志显示:
2023-02-14T11:24:12.9877442Z Step 27/50 : RUN sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
2023-02-14T11:24:13.0005547Z ---> Running in a7a3ed4e4230
2023-02-14T11:24:14.0556490Z Reading package lists...
2023-02-14T11:24:14.2368492Z Building dependency tree...
2023-02-14T11:24:14.2373749Z Reading state information...
2023-02-14T11:24:14.4506218Z The following additional packages will be installed:
2023-02-14T11:24:14.4512003Z libodbc1 odbcinst odbcinst1debian2 unixodbc
2023-02-14T11:24:14.4547419Z Suggested packages:
2023-02-14T11:24:14.4548055Z unixodbc-bin
2023-02-14T11:24:14.4818545Z The following NEW packages will be installed:
2023-02-14T11:24:14.4825198Z libodbc1 msodbcsql17 odbcinst odbcinst1debian2 unixodbc
2023-02-14T11:24:14.5628173Z 0 upgraded, 5 newly installed, 0 to remove and 10 not upgraded.
2023-02-14T11:24:14.5629831Z Need to get 1,403 kB of archives.
2023-02-14T11:24:14.5630312Z After this operation, 1,059 kB of additional disk space will be used.
2023-02-14T11:24:14.5630974Z Get:1 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 libodbc1 amd64 2.3.11 [486 kB]
2023-02-14T11:24:14.6116793Z Get:2 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 odbcinst1debian2 amd64 2.3.11 [99.7 kB]
2023-02-14T11:24:14.6131997Z Get:3 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 odbcinst amd64 2.3.11 [21.3 kB]
2023-02-14T11:24:14.6137953Z Get:4 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 unixodbc amd64 2.3.11 [51.5 kB]
2023-02-14T11:24:14.6146273Z Get:5 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 msodbcsql17 amd64 17.10.2.1-1 [745 kB]
2023-02-14T11:24:14.8246420Z [91mdebconf: delaying package configuration, since apt-utils is not installed
2023-02-14T11:24:14.8685476Z [0mFetched 1,403 kB in 0s (10.5 MB/s)
2023-02-14T11:24:14.8975174Z Selecting previously unselected package libodbc1:amd64.
2023-02-14T11:24:14.9027991Z (Reading database ...
2023-02-14T11:24:14.9028621Z (Reading database ... 5%
2023-02-14T11:24:14.9028984Z (Reading database ... 10%
2023-02-14T11:24:14.9029349Z (Reading database ... 15%
2023-02-14T11:24:14.9029712Z (Reading database ... 20%
2023-02-14T11:24:14.9036996Z (Reading database ... 25%
2023-02-14T11:24:14.9037427Z (Reading database ... 30%
2023-02-14T11:24:14.9037786Z (Reading database ... 35%
2023-02-14T11:24:14.9038144Z (Reading database ... 40%
2023-02-14T11:24:14.9038503Z (Reading database ... 45%
2023-02-14T11:24:14.9038860Z (Reading database ... 50%
2023-02-14T11:24:14.9039200Z (Reading database ... 55%
2023-02-14T11:24:14.9069635Z (Reading database ... 60%
2023-02-14T11:24:14.9091296Z (Reading database ... 65%
2023-02-14T11:24:14.9171951Z (Reading database ... 70%
2023-02-14T11:24:14.9209030Z (Reading database ... 75%
2023-02-14T11:24:14.9287303Z (Reading database ... 80%
2023-02-14T11:24:14.9321749Z (Reading database ... 85%
2023-02-14T11:24:14.9348514Z (Reading database ... 90%
2023-02-14T11:24:14.9369616Z (Reading database ... 95%
2023-02-14T11:24:14.9370004Z (Reading database ... 100%
2023-02-14T11:24:14.9370415Z (Reading database ... 64137 files and directories currently installed.)
2023-02-14T11:24:14.9398390Z Preparing to unpack .../libodbc1_2.3.11_amd64.deb ...
2023-02-14T11:24:14.9410458Z Unpacking libodbc1:amd64 (2.3.11) ...
2023-02-14T11:24:14.9446555Z dpkg: error processing archive /var/cache/apt/archives/libodbc1_2.3.11_amd64.deb (--unpack):
2023-02-14T11:24:14.9448446Z trying to overwrite '/usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0', which is also in package libodbc2:amd64 2.3.9-5
2023-02-14T11:24:14.9453201Z dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
2023-02-14T11:24:14.9600783Z Selecting previously unselected package odbcinst1debian2:amd64.
2023-02-14T11:24:14.9657111Z Preparing to unpack .../odbcinst1debian2_2.3.11_amd64.deb ...
2023-02-14T11:24:14.9670061Z Unpacking odbcinst1debian2:amd64 (2.3.11) ...
2023-02-14T11:24:14.9702481Z dpkg: error processing archive /var/cache/apt/archives/odbcinst1debian2_2.3.11_amd64.deb (--unpack):
2023-02-14T11:24:14.9703365Z trying to overwrite '/usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0', which is also in package libodbcinst2:amd64 2.3.9-5
2023-02-14T11:24:14.9712820Z dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
2023-02-14T11:24:14.9879447Z Selecting previously unselected package odbcinst.
2023-02-14T11:24:14.9879982Z Preparing to unpack .../odbcinst_2.3.11_amd64.deb ...
2023-02-14T11:24:14.9896590Z Unpacking odbcinst (2.3.11) ...
2023-02-14T11:24:14.9924471Z dpkg: error processing archive /var/cache/apt/archives/odbcinst_2.3.11_amd64.deb (--unpack):
2023-02-14T11:24:14.9925203Z trying to overwrite '/etc/odbc.ini', which is also in package unixodbc-common 2.3.9-5
2023-02-14T11:24:15.0031636Z Selecting previously unselected package unixodbc.
2023-02-14T11:24:15.0086839Z Preparing to unpack .../unixodbc_2.3.11_amd64.deb ...
2023-02-14T11:24:15.0099782Z Unpacking unixodbc (2.3.11) ...
2023-02-14T11:24:15.0345718Z Selecting previously unselected package msodbcsql17.
2023-02-14T11:24:15.0408910Z Preparing to unpack .../msodbcsql17_17.10.2.1-1_amd64.deb ...
2023-02-14T11:24:15.1308373Z debconf: unable to initialize frontend: Dialog
2023-02-14T11:24:15.1308981Z debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
2023-02-14T11:24:15.1309532Z debconf: falling back to frontend: Readline
2023-02-14T11:24:15.1900197Z Unpacking msodbcsql17 (17.10.2.1-1) ...
2023-02-14T11:24:15.2861152Z Errors were encountered while processing:
2023-02-14T11:24:15.2911953Z /var/cache/apt/archives/libodbc1_2.3.11_amd64.deb
2023-02-14T11:24:15.2913469Z /var/cache/apt/archives/odbcinst1debian2_2.3.11_amd64.deb
2023-02-14T11:24:15.2913914Z /var/cache/apt/archives/odbcinst_2.3.11_amd64.deb
2023-02-14T11:24:15.3017753Z [91mW: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/google-chrome.list:3 and /etc/apt/sources.list.d/google.list:1
2023-02-14T11:24:15.3019957Z W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/google-chrome.list:3 and /etc/apt/sources.list.d/google.list:1
2023-02-14T11:24:15.3021244Z E: Sub-process /usr/bin/dpkg returned an error code (1)
2023-02-14T11:24:15.4448720Z [0mThe command '/bin/sh -c sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17' returned a non-zero code: 100
2023-02-14T11:24:15.4513491Z ##[error]The command '/bin/sh -c sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17' returned a non-zero code: 100
2023-02-14T11:24:15.4573901Z ##[error]The process '/usr/bin/docker' failed with exit code 100
2023-02-14T11:24:15.4707763Z ##[section]Finishing: Build and push an image to container registry
与之前的成功运行相比
2023-02-11T19:37:57.4354185Z Step 26/48 : RUN sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
2023-02-11T19:37:57.4581744Z ---> Running in 4a4103163268
2023-02-11T19:37:58.7290566Z Reading package lists...
2023-02-11T19:37:58.9192709Z Building dependency tree...
2023-02-11T19:37:58.9198211Z Reading state information...
2023-02-11T19:37:59.0809251Z The following additional packages will be installed:
2023-02-11T19:37:59.0810747Z odbcinst unixodbc
2023-02-11T19:37:59.1386647Z The following NEW packages will be installed:
2023-02-11T19:37:59.1387518Z msodbcsql17 odbcinst unixodbc
2023-02-11T19:37:59.1701331Z 0 upgraded, 3 newly installed, 0 to remove and 9 not upgraded.
2023-02-11T19:37:59.1702280Z Need to get 781 kB of archives.
2023-02-11T19:37:59.1703277Z After this operation, 164 kB of additional disk space will be used.
2023-02-11T19:37:59.1704324Z Get:1 http://archive.ubuntu.com/ubuntu jammy/universe amd64 odbcinst amd64 2.3.9-5 [10.0 kB]
2023-02-11T19:37:59.1755448Z Get:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 unixodbc amd64 2.3.9-5 [26.8 kB]
2023-02-11T19:37:59.2515376Z Get:3 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 msodbcsql17 amd64 17.10.2.1-1 [745 kB]
2023-02-11T19:37:59.5305134Z [91mdebconf: delaying package configuration, since apt-utils is not installed
2023-02-11T19:37:59.5643111Z [0mFetched 781 kB in 0s (4,644 kB/s)
2023-02-11T19:37:59.5877856Z Selecting previously unselected package odbcinst.
2023-02-11T19:37:59.5980771Z (Reading database ...
2023-02-11T19:37:59.5982730Z (Reading database ... 5%
2023-02-11T19:37:59.5984208Z (Reading database ... 10%
2023-02-11T19:37:59.5985015Z (Reading database ... 15%
2023-02-11T19:37:59.5985666Z (Reading database ... 20%
2023-02-11T19:37:59.5986961Z (Reading database ... 25%
2023-02-11T19:37:59.5987600Z (Reading database ... 30%
2023-02-11T19:37:59.5988115Z (Reading database ... 35%
2023-02-11T19:37:59.5988607Z (Reading database ... 40%
2023-02-11T19:37:59.5989105Z (Reading database ... 45%
2023-02-11T19:37:59.5989577Z (Reading database ... 50%
2023-02-11T19:37:59.5990064Z (Reading database ... 55%
2023-02-11T19:37:59.6033063Z (Reading database ... 60%
2023-02-11T19:37:59.6064217Z (Reading database ... 65%
2023-02-11T19:37:59.6082834Z (Reading database ... 70%
2023-02-11T19:37:59.6110601Z (Reading database ... 75%
2023-02-11T19:37:59.6195444Z (Reading database ... 80%
2023-02-11T19:37:59.6237561Z (Reading database ... 85%
2023-02-11T19:37:59.6271852Z (Reading database ... 90%
2023-02-11T19:37:59.6295395Z (Reading database ... 95%
2023-02-11T19:37:59.6295782Z (Reading database ... 100%
2023-02-11T19:37:59.6296217Z (Reading database ... 64137 files and directories currently installed.)
2023-02-11T19:37:59.6312515Z Preparing to unpack .../odbcinst_2.3.9-5_amd64.deb ...
2023-02-11T19:37:59.6335557Z Unpacking odbcinst (2.3.9-5) ...
2023-02-11T19:37:59.6575371Z Selecting previously unselected package unixodbc.
2023-02-11T19:37:59.6628297Z Preparing to unpack .../unixodbc_2.3.9-5_amd64.deb ...
2023-02-11T19:37:59.6645776Z Unpacking unixodbc (2.3.9-5) ...
2023-02-11T19:37:59.6936338Z Selecting previously unselected package msodbcsql17.
2023-02-11T19:37:59.6983964Z Preparing to unpack .../msodbcsql17_17.10.2.1-1_amd64.deb ...
2023-02-11T19:37:59.7900514Z debconf: unable to initialize frontend: Dialog
2023-02-11T19:37:59.7901298Z debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
2023-02-11T19:37:59.7901875Z debconf: falling back to frontend: Readline
2023-02-11T19:37:59.8448156Z Unpacking msodbcsql17 (17.10.2.1-1) ...
2023-02-11T19:37:59.9600325Z Setting up odbcinst (2.3.9-5) ...
2023-02-11T19:37:59.9641147Z Setting up unixodbc (2.3.9-5) ...
2023-02-11T19:37:59.9694826Z Setting up msodbcsql17 (17.10.2.1-1) ...
2023-02-11T19:37:59.9786648Z odbcinst: Driver installed. Usage count increased to 1.
2023-02-11T19:37:59.9787144Z Target directory is /etc
2023-02-11T19:38:00.0084995Z [91mW: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/google-chrome.list:3 and /etc/apt/sources.list.d/google.list:1
2023-02-11T19:38:00.0088695Z W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/google-chrome.list:3 and /etc/apt/sources.list.d/google.list:1
2023-02-11T19:38:03.7513881Z [0mRemoving intermediate container 4a4103163268
2023-02-11T19:38:03.7514509Z ---> 5a93ebb5f6af
答案1
原因如下:
2023-02-14T11:40:11.2355856Z dpkg: error processing archive /tmp/apt-dpkg-install-dulMkE/2-odbcinst_2.3.11_amd64.deb (--unpack):
2023-02-14T11:40:11.2361186Z trying to overwrite '/etc/odbc.ini', which is also in package unixodbc-common 2.3.9-5
这是一个已知不兼容性尝试安装 Microsoft 的 ODBC 包和系统上的 unixodbc 包时。它们是不是可共同安装,这是 Microsoft 在存储库中实现的限制。
由于这两个包发生冲突,您需要执行以下操作之一:
- 删除
unixodbc-common
并安装任何依赖它的东西msodbcsql17
,或者 - 放弃安装的努力
msodbcsql17
。
不幸的是,目前没有其他方法可以解决这个问题,而且这似乎是微软包装的一个全球性问题。您可能希望联系微软并将其报告为包装问题。
/etc/apt/sources.list.d/
(此外,您还配置了两次 Google Chrome 存储库,请删除其中包含 Chrome 存储库的条目/文件之一)
答案2
在安装 msodbcsql17 之前,它尝试安装其他 3 个包 -
The following additional packages will be installed:
libodbc1 odbcinst odbcinst1debian2
但正如 @Thomas Ward 所说,Microsoft 的 ODBC 包和系统上的 unixodbc 包不能同时安装。这里 'apt' 因版本冲突而失败,因为它试图安装两者,但无法安装,因为这两个包试图安装同一个文件。这个问题已在多个论坛但由于问题出在微软方面,因此人们只能在此之前提供临时的破解方法。
但现在微软似乎已经提供了一个修复程序,我使用了他们自己页面上的以下代码安装适用于 SQL Server (Linux) 的 Microsoft ODBC 驱动程序因此下面的代码片段可以完美运行-
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
我发现另一种同样有效的方法是在 Microsoft 软件包之前安装 unixodbc-dev。以下是另一个有效的代码示例-
apt-get install -y unixodbc-dev
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get -q -y install msodbcsql17