Python 运行 os.system("kinit") 时出错 - sh: 1: kinit: 未找到

Python error when running os.system("kinit") - sh: 1: kinit: not found

我正在构建 python docker 映像并正在测试 kinit 功能。当我 运行 以下 `os.system('kinit') 我收到一个错误

FROM python:3.5.7-buster

ADD krb5.conf /etc/krb5.conf
ADD krb5.keytab /etc/krb5.keytab

COPY requirements.txt .

RUN apt-get update && apt-get install -y libsasl2-dev libsasl2-2 libsasl2-modules-gssapi-mit openssl libkrb5-dev krb5-config kinit kinit-dev
RUN pip install --no-cache-dir -r requirements.txt

要求:

impyla==0.15.0 sasl==0.2.1 thrift_sasl==0.2.1 thriftpy==0.3.9 thriftpy2==0.4.0 numpy pandas openssl-python==0.1.1 kerberos

Python代码:

import ssl
from impala.dbapi import connect
import os

os.system("kinit")

我收到错误 sh: 1: kinit: not found

kinit Debian 软件包与 Kerberos 无关:

# apt-cache search kinit
kinit - process launcher to speed up launching KDE applications
kinit-dev - process launcher to speed up launching KDE applications

包含 /usr/bin/kinit 二进制文件的软件包是 krb5-user 软件包:

# dpkg -S /usr/bin/kinit
krb5-user: /usr/bin/kinit

# apt-cache search krb5-user
krb5-user - basic programs to authenticate using MIT Kerberos

您的 Dockerfile 应如下所示:

FROM python:3.5.7-buster

ADD krb5.conf /etc/krb5.conf
ADD krb5.keytab /etc/krb5.keytab

COPY requirements.txt .

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y libsasl2-dev libsasl2-2 libsasl2-modules-gssapi-mit openssl libkrb5-dev krb5-config krb5-user
RUN pip install --no-cache-dir -r requirements.txt

注意:krb5-user安装是交互式的,需要将DEBIAN_FRONTEND=noninteractive设置为