我们在构建 docker 映像时遇到了 WORKDIR 问题.是否可以打印 WORKDIR 的值?
We have a problem with the WORKDIR when we building a docker image. Is it possible to print the value of WORKDIR?
我们试过了:
ECHO ${WORKDIR}但是没有这样的指令ECHO
推荐答案在构建过程中,Docker 没有内置的方法来打印 WORKDIR.您可以检查图像/图层的最终工作目录:
There's no builtin way for Docker to print the WORKDIR during a build. You can inspect the final workdir for an image/layer:
docker image inspect {image-name} | jq '.[].Config.WorkingDir'可以通过打印 shells 默认工作目录来查看 Linux 容器构建步骤 workdir:
It's possible to view a Linux containers build steps workdir by printing the shells default working directory:
RUN pwd或者shell经常将工作目录存放在PWD环境变量中
or the shell often stores the working directory in the PWD environment variable
RUN echo "$PWD"如果您使用的是较新版本的 dockers BuildKit,则需要使用 --progress=plain
If you are using newer versions of dockers BuildKit, stdout will need to be enabled with --progress=plain
docker build --progress=plain .更多推荐
构建 docker 映像时是否可以显示“WORKDIR"?
发布评论