Docker下载并在Hugo版本中安装二进制文件
我试图安装 hugo docker文件中的工具按照此指南
https://gohugo.io.io/getting-started/installing/#debian-and-wbian-and-ubuntu
gohugo.io/getting-started/installing/#debian-and-ubuntu DID是以下
FROM debian:11.3
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
hugo
RUN ["hugo version"]
docker构建工作的工作,但最后一个语句运行[“ Hugo版本”]
错误是> [3/3]运行[“ Hugo版本”]:#7 0.173 Container_linux.go:380:启动容器流程引起的造成:exec:“ Hugo版本”:$ PATH中找不到可执行文件
如何添加它在路径上,我认为如果下载它应该在那里,但没有。有什么想法吗?
更新
当我将其更改为 运行Hugo版本
我在没有印刷版本的情况下获得以下输出,任何想法我在这里缺少什么?
#7 [3/3] RUN hugo version
#7 sha256:d032565cca2aac041e6791690dbcb32f2dc9d024d05699f67d21eb51cb39b0fc
#7 CACHED
#8 exporting to image
#8 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#8 exporting layers done
#8 writing image sha256:db76bafd84f0bdf930625714a72e2d0e1967578c48df0ffd0b4fc869c802f18f done
#8 DONE 0.0s
im trying to install the Hugo tool in docker file following this guideline
https://gohugo.io/getting-started/installing/#debian-and-ubuntu
What I did is the following
FROM debian:11.3
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
hugo
RUN ["hugo version"]
The docker build working except the last statement RUN ["hugo version"]
the error is > [3/3] RUN ["hugo version"]: #7 0.173 container_linux.go:380: starting container process caused: exec: "hugo version": executable file not found in $PATH
how can I add it to the path, I assume that if I download it it should be there but no. any idea?
UPDATE
when I change it toRUN hugo version
I got the following output without the version printed, any idea what am I missing here?
#7 [3/3] RUN hugo version
#7 sha256:d032565cca2aac041e6791690dbcb32f2dc9d024d05699f67d21eb51cb39b0fc
#7 CACHED
#8 exporting to image
#8 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#8 exporting layers done
#8 writing image sha256:db76bafd84f0bdf930625714a72e2d0e1967578c48df0ffd0b4fc869c802f18f done
#8 DONE 0.0s
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当Docker Build执行行:
运行Hugo版本
,然后默认情况下,它不会显示未从缓存中加载的运行命令的输出。因此,您没有看到它的输出。当我使用此标志运行Docker build命令时:

- progress = plain
,我可以看到run命令的“非速度”行的输出。可以在中找到更多详细信息。这是我收到的输出的屏幕截图:一些观察:
- progress = plain
显示未缓存或新鲜执行的行的中间步骤。因此,如果您想查看输出,则需要首先使用命令清除docker构建缓存和所有悬空图像:
在此步骤之后,您将能够新鲜执行所有的构建步骤,并能够看到输出
运行Hugo版本
。cmd
或entrypoint
命令。仅当您从已经构建的图像(而不是构建图像时)旋转容器时,才执行使用这些DockerFile指示指定的命令。例如,如果我的dockerfile是:构建过程中的输出是:

指令
CMD Hugo版本
未执行。通过命令从此构建图像中运行一个容器后:

然后,只有我才能看到此说明的输出。
我希望这有助于建立理解!
When docker build executes the line:
RUN hugo version
, then by default, it does not show the output of the run commands that were not loaded from the cache. And hence you are not seeing its output.When I ran docker build command with this flag:

--progress=plain
, I could see the output of "non-cached" line for RUN command. More details can be found in this answer. Here is the screenshot for the output I got:A few observations:
--progress=plain
shows intermediate steps of the lines that are not cached or freshly executed.So, if you wish to view the output, you need to first clear your docker build cache and all the dangling images using the commands:
After this step, you will be able to freshly execute all your build steps and will be able to see output of
RUN hugo version
.CMD
orENTRYPOINT
command. The command specified with these dockerfile instructions are executed only when you spin a container from the image that you have already built, not when the image is being built. For example if my dockerfile is:The output during build would be:

The instruction
CMD hugo version
is not executed.After I run a container from this built image via command:

Then only I would see the output of this instruction coming.
I hope this helps in building the understanding!
您可以使用
docker build
使用- no-cache
来查看没有缓存的输出:完整dockerfile:
完整命令:
此显示:
另外,您需要保留使用[] -syntax时命令和参数分开,因此看起来像
run [“ hugo”,“ version”]
You can run the
docker build
command with--no-cache
to see the output without cache:Full Dockerfile:
Full command:
This displays:
Also, you need to keep the command and parameters separate when using the []-syntax, so it would look like
RUN ["hugo", "version"]