gpt4 book ai didi

docker - Dockerfile wget失败

转载 作者:行者123 更新时间:2023-12-02 18:48:06 25 4
gpt4 key购买 nike

我有以下代码

RUN apt-get update
RUN apt-get install -y wget #install wget lib
RUN mkdir -p example && cd example #create folder and cd to folder
RUN WGET -r https://host/file.tar && tar -xvf *.tar # download tar file to example folder and untar it in same folder
RUN rm -r example/*.tar # remove the tar file
RUN MV example/foo example/bar # rename untar directory from foo to bar

但我得到以下错误:
/bin/sh: 1: WGET: not found
tar: example/*.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now


我是Docker的新手。

最佳答案

Dockerfile中的每个后续RUN命令将位于/目录的上下文中。因此,您的.tar文件不在example/目录中,它实际上在/目录中,因为您的“cd到文件夹”对后续的RUN命令没有任何意义。除了执行cd example之外,还可以在运行WORKDIR example之前执行wget,例如:

RUN apt-get update
RUN apt-get install -y wget #install wget lib
RUN mkdir -p example # create folder and cd to folder
WORKDIR example/ # change the working directory for subsequent commands
RUN wget -r https://host/file.tar && tar -xvf *.tar # download tar file to example folder and untar it in same folder
RUN rm -r example/*.tar # remove the tar file
RUN mv example/foo example/bar # rename untar directory from foo to bar

或者,在 cd example && ... some command目录中要执行的任何命令之前添加 example

关于docker - Dockerfile wget失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54717736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com