簡體   English   中英

如何使用 wget 作為 Dockerfile 運行命令將文件下載到特定路徑?

[英]How to download a file to a specific path using wget as a Dockerfile run command?

我的應用程序目錄結構如下所示:

Root/
    app.py
    requirements.txt

    imageHelpers/
        helpers.py
        config.yml
        model.pth

我不想將我的model.pth復制到服務器,而是想在構建容器時從 web 下載它。 我希望我的model.pth的確切路徑為imageHelpers/model.pth wget -O PATH_TO_MODEL URL的路徑應該是什么? 下面是我的Dockerfile

FROM python:3.9

WORKDIR /fast_api_test

COPY ./requirements.txt /fast_api_test/requirements.txt

RUN pip3 install -r /fast_api_test/requirements.txt

COPY . .

RUN python -m pip install 'git+https://github.com/facebookresearch/detectron2.git' \
    && wget -q -O /imageHelpers/model.pth https://MY_URL/model.pth

EXPOSE 5000

CMD ["uvicorn",  "app:app", "--host", "0.0.0.0", "--port", "5000"]

如果需要,請使用AWS + Ubuntu

當我運行sudo docker build -t fast_api. ,它給了我錯誤:

/fast_api_test/imageHelpers/model.pth: No such file or directory

The command '/bin/sh -c pip3 install --upgrade -r /fast_api_test/requirements.txt     && python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'     && wget -q -O /fast_api_test/imageHelpers/model.pth https://MY_URL/model.pth' returned a non-zero code: 1


COPY(如 ADD)嘗試從圖像外部復制到圖像中。

由於文件已通過 wget 下載到圖像內部,因此您需要使用命令行 cp 命令

嘗試這個:

RUN cp <downloaded_file> /fast_api_test
COPY . /fast_api_test

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM