Docker command/option to display or list the build context
Answers above are great, but there is a low-tech solution for most cases - ncdu
. This utility will show pretty and interactive tree structure with sizes. It has an option that will take patterns from a file and exclude them from scan. So you can just do ncdu -X .dockerignore
. You will get something like this:
This is pretty close to what you will get in your docker image. One caveat is thou if you add a dot directory (like .yarn
) into an image, it will not show in ncdu
output.
The only way would be to add the current directory to an specific directory and list it.
Try building with this Dockerfile:
FROM busybox
RUN mkdir /tmp/build/
# Add context to /tmp/build/
COPY . /tmp/build/
Build it with:
docker build -t test .
List all the files and directories in /tmp/build:
docker run --rm -it test find /tmp/build