我需要pip install在 initcontainer 中運行命令。我正在使用python:3.9-slim-buster 影像。
我創建了以下代碼,但是出現以下錯誤:
/usr/local/bin/python3:沒有名為 pip install moduleexample 的模塊
代碼:
spec:
volumes:
- name: agent-volume
emptyDir: {}
initContainers:
- name: dd-apm-init
image: python:3.9-slim-buster
command: ["python3", "-m", "pip install moduleexample"]
resources: {}
volumeMounts:
- name: agent-volume
mountPath: /usr/local/lib/python3.9/site-packages
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
有什么建議?
==================================================== ============== 更新:
Pip Install與影像一起使用python:3.8-slim-buster。
似乎 3.9 pip 正在安裝site-packages,而它不包含在默認值中sys.path。
當我嘗試從site-packages. 我收到拒絕訪問錯誤。
uj5u.com熱心網友回復:
嘗試拆分整個命令:
["python3", "-m", "pip", "install", "moduleexample"]
uj5u.com熱心網友回復:
您以錯誤的格式給出了命令。應該是這樣的——
spec:
volumes:
- name: agent-volume
emptyDir: {}
initContainers:
- name: dd-apm-init
image: python:3.9-slim-buster
command: ["python3", "-m", "pip", "install", "moduleexample"]
resources: {}
volumeMounts:
- name: agent-volume
mountPath: /usr/local/lib/python3.9/site-packages
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
希望這會為您解決問題!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/421332.html
標籤:
下一篇:Docker不創建資料庫
