我需要在 docker 镜像中安装一些 python 包并将该镜像部署为 kubernetes 部署。下面是我的 Dockerfile 和部署文件
FROM python:3.7-slim
# install FreeTDS and dependencies
RUN apt-get update \
&& apt-get install unixodbc -y \
&& apt-get install unixodbc-dev -y \
&& apt-get install freetds-dev -y \
&& apt-get install freetds-bin -y \
&& apt-get install tdsodbc -y \
&& apt-get install --reinstall build-essential -y
# populate "ocbcinst.ini"
RUN echo "[FreeTDS]\n\
Description = FreeTDS unixODBC Driver\n\
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\n\
Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so" >> /etc/odbcinst.ini
# install pyodbc (and, optionally, sqlalchemy)
RUN pip install --trusted-host pypi.python.org pyodbc==4.0.26 sqlalchemy==1.3.5 pyarrow
# run app.py upon container launch
CMD ["python3"]
docker 镜像构建命令
docker build pyarrow-custom:latest .
apiVersion: apps/v1
kind: Deployment
metadata:
name: python-odbc-custom
labels:
app: python-odbc-custom
spec:
replicas: 1
selector:
matchLabels:
app: python-odbc-custom
template:
metadata:
name: python-odbc-custom
labels:
app: python-odbc-custom
spec:
containers:
- name: python-odbc-custom
image: "pyarrow-custom:latest"
command: ['python3']
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8099
kubectl 命令
kubectl apply -f python-obbc-deployment.yaml
但是,在创建容器之后,它就完成了。当我在 CMD 中给出 python3 时,我想继续在那里运行 python shell。我该怎么做?