[英]C:\Users\krish\Desktop\code\hello> docker-compose up can't find a suitable configuration file in this directory or any parent: not found
[英]Docker can't find directory
我想為我的腳本創建一個泊塢窗。
我的dockerfile
是 =
FROM python:3.8
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
ENTRYPOINT ["python3"]
CMD ["main.py btcusdt"]
設置此 Dockerfile 后,
sudo docker build -t image_name_test:tag_name_test .
我的圖像 ID:72e5ee15f5a5
sudo docker run 72e5ee15f5a5
錯誤是:
python3: can't open file 'main.py btcusdt': [Errno 2] No such file or directory
為什么我的 docker 找不到目錄 main.py ?
感謝您的時間。
這是我的文件:
您將文件名及其參數作為一個單詞引用; 和沒有 Docker 運行的效果一樣
python3 "main.py btcusdt"
這會導致 Python 解釋器查找該名稱(包括空格和參數)作為要運行的腳本的文件名。
如果您使用 JSON 數組“執行形式”,則需要將每個單詞拆分為單獨的 JSON 數組元素。
這種特殊ENTRYPOINT
/ CMD
拆分並沒有真正意義,我會將兩半合並成一個CMD
。 所以:
# no ENTRYPOINT
CMD ["python3", "main.py", "btcusdt"]
更好的是,如果您以“shebang”行開始腳本,作為腳本的第一行
#!/usr/bin/env python3
並使腳本可執行
# on the host, committed to source control
chmod +x main.py
那么你可以完全省略python3
解釋器
# still no ENTRYPOINT; still split into separate words
CMD ["./main.py", "btcusdt"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.