Docker command/option to display or list the build context
是否有命令/选项来显示或列出发送到docker守护进程以构建映像的上下文?
1 2 3 | $ docker build -t"image-name" Sending build context to Docker daemon 8.499 MB ... |
通过在
唯一的方法是将当前目录添加到特定目录并列出它。
尝试使用此dockerfile生成:
1 2 3 4 5 | FROM busybox RUN mkdir /tmp/build/ # Add context to /tmp/build/ COPY . /tmp/build/ |
用:
1 | docker build -t test . |
列出/tmp/build中的所有文件和目录:
1 | docker run --rm -it test find /tmp/build |
更新答案:自2017年以来,Docker建议使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # debug and list the docker build context so that you can minimmize it # # usage: # docker build -f docker/context.Dockerfile -t test/buildcontext . # ###################### FROM busybox RUN mkdir /tmp/build/ # Add context to /tmp/build/ COPY . /tmp/build # this last command outputs the list of files added to the build context: RUN find /tmp/build/ |