不是直接的,我知道,但间接地它不会那么难。您可以COPY将整个构建上下文转换为图像,然后对该内容做任何您想做的事情。
FROM busybox
WORKDIR /stuff
# Just copy everything to the image
COPY . .
# Some default CMD is usually a good idea
CMD du -m | sort -n
# Build and run the image
docker build -t where-is-my-space -f Dockerfile.debug .
# The default `CMD` lists directories in the copied content
# sorted by size
docker run --rm where-is-my-space
# Huh, let's dig in more
docker run --rm where-is-my-space ls -l data/unexpected
# Or with an interactive shell (note, busybox doesn't have bash)
docker run --rm -it where-is-my-space sh
# All done, let's clean up
docker rmi where-is-my-space