2

I am building a python docker image and am testing out the kinit capability. When I run the following `os.system('kinit') I am receiving an error

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

Requirements:

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 code:

import ssl
from impala.dbapi import connect
import os

os.system("kinit")

I get the error sh: 1: kinit: not found

sectechguy
  • 2,037
  • 4
  • 28
  • 61

1 Answers1

4

The kinit Debian package is not-related to Kerberos:

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

The package that contains the /usr/bin/kinit binary is the krb5-user package:

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

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

Your Dockerfile should look like this:

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

Note: krb5-user installation is interactive, you need to set DEBIAN_FRONTEND=noninteractive to make it unattended.

Eduardo Baitello
  • 10,469
  • 7
  • 46
  • 74
  • 3
    Of course, with unattended installation, you get a default configuration which is probably not useful. You can preseed `debconf` with suitable configuration values (though see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=829671) or put your own `/etc/krb5.conf` to replace it. – tripleee Nov 04 '19 at 17:10
  • Thank you @Eduardo Baitello – sectechguy Nov 04 '19 at 20:26