Closed gavenkoa closed 9 months ago
I want to restate that podman
scans entire context directory hierarchy before is moves to any STEP! It is seen in the procmon.exe
. Steps are printed to the screen much later (~5 min) including COPY
command which might trigger the scan for files.
It is actually copying the entire context directory into the VM to be able to build the container. It can not figure out what is needed and not needed in the context directory until the Containerfile is processed. I believe you can use .containerignore or .dockerignore to cut down on the amount of files copied.
It would be much faster if you just moved all of the content required for the build into the test directory and then just ran the build from there.
I suspected of such behavior as I saw intensive TCP communication.
The spec https://docs.docker.com/build/building/context/#filesystem-contexts
*What is a build context?** When your build context is a local directory, a remote Git repository, or a tar file, then that becomes the set of files that the builder can access during the build. A filesystem build context is processed recursively: When you specify a local directory or a tarball, all subdirectories are included
Local context This makes files and directories in the current working directory available to the builder. The builder loads the files it needs from the build context when needed.
omits description of this behavior, wording makes files and directories in the current working directory available to the builder is evasive - leaving the room for further optimization, like avoiding copying the data prematurely and only taking what is referenced in COPY
/ ADD
...
Anyway I faced the issue only because #18840 is not yet fixed.
As a workaround I'll make a cp
or even tar
workaround as .containerignore
is an extra complication - need to understand the syntax & it is quite weak tool, while with tar
I am familiar...
Does it make sense to update the docs? It looks like copying of context dir to a VM is WSL 2 specific operation... Will I face this enormous delay issue on Linux?
ADD
command understands TAR archives, the best way is to place a tar file to a build context context:
tar -zcf my.tar.gz --exclude=.git --exclude=node_modules -C ../ui-proj .
podman build --tag test .
and in Containerfile
:
RUN mkdir -p /work
WORKDIR /work
ADD my.tar.gz .
Docker documentation also mentions that every file from build context is copied to the Docker server...
Issue Description
When I run
podman build
on Windows 10 from the directory, containing other projects podman recursively reads all the subdirectories, with a big hierarchy is leads to minutes in delay.I see recursive behavior in procmon.exe, for every file it performs (and similar to every directory):
Steps to reproduce the issue
Run
podman build -f some/Containerfile .
from a directory with lots of files & directories (node_modules
are good candidate xD).Describe the results you received
Slow
podman build
execution.Describe the results you expected
I expect
podman build
to be nearly instantaneous.podman info output
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
Win 10 + WSL 2.
Additional information
I'm facing the #18840 so to include external to the build directory files I moved context up and unrelated directories are scanned by podman...
My final step is
STEP 6/6: COPY test .
- so podman shouldn't read any non "test" files.