我正在构建一个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
设置为make it unattended。关于python - 运行os.system时出现Python错误(“kinit”)-sh:1:kinit:找不到,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58697203/