运行 os.system 时出现 Python 错误 ("kinit") - sh : 1: kinit: not found

标签 python python-3.x docker kerberos

我正在构建一个 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:找不到

最佳答案

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 .

关于运行 os.system 时出现 Python 错误 ("kinit") - sh : 1: kinit: not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58697203/

相关文章:

python - 将多个 Parquet 文件中的数据检索到一个数据帧中 (Python)

python - 如何将数据附加到 TensorFlow tfrecords 文件

python - 图像压缩后得到的灰度图像

Python:为什么这些代码行显示不同的值?

python - 类型错误 : '<' not supported between instances of 'tuple' and 'str'

windows - 在 Windows dockerfile 中转义美元符号

python - 为什么 Dramatiq 在 Docker 容器中启动失败?

python子进程输出到列表或文件

python - Pandas 中列的多个索引

docker - 在代理后运行Docker