7

我正在尝试使用 RHEL 8 UBI 构建自定义 docker 容器。作为其中的一部分,我想安装 MSSQL 17 ODBC 驱动程序。我已按照此处的 Microsoft 文档中概述的步骤进行操作: https ://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql- server?view=sql-server-ver15#redhat17

并将 Microsoft 存储库添加到我的yum.repos.d目录中,但是当我尝试构建容器时,出现以下错误:nothing provides e2fsprogs needed by msodbcsql17-17.6.1.1-1.x86_64

当我对此进行深入研究时,它看起来好像对于 RHEL-7 微软建议手动安装 e2fsprogs 您可以在此处看到:https ://docs.microsoft.com/en-us/sql/connect/odbc /linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#offline-installation

不幸的是,这在 RHEL-8 中是不可能的,因为 e2fsprogs-static 已被删除:https ://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/considerations_in_adopting_rhel_8/index#removed-packages_changes-到包

构建的完整输出是:

$  docker build -f ./test.dockerfile -t daark:1 .
Sending build context to Docker daemon  25.77MB
Step 1/7 : FROM registry.redhat.io/ubi8/ubi
 ---> a1f8c9699786
Step 2/7 : RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
 ---> Using cache
 ---> 90b3e1514239
Step 3/7 : RUN yum search odbc
 ---> Using cache
 ---> b26f78d0da28
Step 4/7 : RUN yum search msodbcsql17
 ---> Using cache
 ---> c6f7751b97dc
Step 5/7 : ENV ACCEPT_EULA=Y
 ---> Using cache
 ---> 2b0003944673
Step 6/7 : RUN yum install -y unixODBC unixODBC-devel
 ---> Using cache
 ---> 1d0b8c594905
Step 7/7 : RUN yum install -y msodbcsql17
 ---> Running in 67c30e75fb42
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:08:11 ago on Wed Aug  5 09:36:32 2020.
Error:
 Problem: cannot install the best candidate for the job
  - nothing provides e2fsprogs needed by msodbcsql17-17.6.1.1-1.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
The command '/bin/sh -c yum install -y msodbcsql17' returned a non-zero code: 1

这个错误很容易重现这里是我用来调试的测试 dockerfile


FROM registry.redhat.io/ubi8/ubi
RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
RUN yum search odbc
RUN yum search msodbcsql17
ENV ACCEPT_EULA=Y
RUN yum install -y unixODBC unixODBC-devel 
RUN yum install -y msodbcsql17

有没有人设法将这个 ODBC 驱动程序安装在基于 RHEL 8 UBI 的容器上?

4

3 回答 3

5

我找到了一个解决方法,希望能帮助下一个人解决这个问题。我没有运行yum install -y msodbcsql17,而是使用 yum 下载 RPM, yum download -y msodbcsql17 然后用于rpm -Uvh --nodeps msodbcsql17*rpm安装它。

您可以使用此泊坞窗文件:

FROM registry.redhat.io/ubi8/ubi
RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
RUN yum search odbc
RUN yum search msodbcsql17
ENV ACCEPT_EULA=Y
RUN yum install -y unixODBC unixODBC-devel 
RUN yum download -y msodbcsql17
RUN rpm -Uvh --nodeps msodbcsql17*rpm
于 2020-08-05T10:46:44.800 回答
2

@daark 感谢您发布您的解决方案。你的解决方案让我克服了我面临的问题。我结束了将您的解决方案修改为以下内容(以防它帮助其他人):

FROM registry.access.redhat.com/ubi8/python-38

USER root
RUN yum update --assumeyes && \
  yum install --assumeyes \
    unixODBC-devel \
  && yum clean all

RUN curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo
RUN yum download -y msodbcsql17
RUN ACCEPT_EULA=y rpm -Uvh --nodeps msodbcsql17*rpm

我尝试将此作为注释添加到@daark 的解决方案中,但正确显示代码太难了。

祝其他面临此问题的人好运

于 2021-05-11T21:43:20.567 回答
1

最新的 msodbcsql17 版本修复了这个问题。文档步骤再次顺利进行。请参阅文档问题

于 2021-08-02T13:14:15.880 回答