Installing dependencies, unpacking an archive, or running a code generator in your project folder creates, checks, reads, and removes many small files through the engine's file sharing. This check does the same in four steps on a folder shared from your machine:
- Create 10 000 one-line files.
- Look up the size of each file.
- Read every file.
- Delete every file.
Each step runs in its own short-lived container with the folder shared in as
-v "$PWD:/bind". The result is the wall-clock time of all four docker run
commands together on your machine, including container startup.
For how durations are taken and how to repeat a check, see Performance checks .
Set up
Pull the image so its download stays out of the timing:
$ mkdir -p ~/perfcheck/small-files && cd ~/perfcheck/small-files
$ docker pull alpine:3.24.1
Run the check
Start from an empty shared folder. This step isn't timed.
$ rm -rf shared && mkdir shared && cd sharedRun the timed command:
$ time ( docker run --rm -v "$PWD:/bind" alpine:3.24.1 sh -c 'cd /bind && i=1; while [ $i -le 10000 ]; do echo $i > f$i; i=$((i+1)); done' && docker run --rm -v "$PWD:/bind" alpine:3.24.1 sh -c 'find /bind -type f -exec stat -c "%s" {} + > /dev/null' && docker run --rm -v "$PWD:/bind" alpine:3.24.1 sh -c 'find /bind -type f -exec cat {} + > /dev/null' && docker run --rm -v "$PWD:/bind" alpine:3.24.1 sh -c 'find /bind -type f -delete' )Record the elapsed time.
Check that the run is valid. The timed block must finish without an error, and the last step must have removed every file:
$ ls -A | wc -l 0Clean up:
$ cd .. $ rm -rf shared