Hi, I would like to use Testcontainers for testing applications with the DB2 12.1 Community docker image (icr.io/db2_community/db2:12.1.0.0).
But starting up the DB2 docker container is very slow. It does not seem to be an issue with testcontainers itself, because it is just as slow when I start the container myself following the instructions and env_list.txt from Installing the Db2 Community Edition Docker image on Windows systems.
$ time docker run -h db2server --name db2server --restart=always --privileged=true -p 50000:50000 --env-file env_list.txt -v D:/db2-community/database:/database icr.io/db2_community/db2 2>&1 | grep -m1 "Setup has completed"
(*) Setup has completed.
real 1m45.566s
user 0m0.015s
sys 0m0.152s
With the following tweaks to env_list.txt, there is some speedup:
TO_CREATE_SAMPLEDB=false
REPODB=false
AUTOCONFIG=false
ARCHIVE_LOGS=false
$ time docker run -h db2server --name db2server --restart=always --privileged=true -p 50000:50000 --env-file env_list_faster.txt -v D:/db2-community/database:/database icr.io/db2_community/db2 2>&1 | grep -m1 "Setup has completed"
(*) Setup has completed.
real 1m5.743s
user 0m0.015s
sys 0m0.030s
But still, over 1 minute startup is not really usable for automated testing scenario.
Even in the official documentation it is mentioned that "After the docker run command is executed, it will take a couple of minutes for the container to finish setting up."
Does anyone have any other tips to improve the startup time?
When starting up from an existing volume mount with initialized DB, there is some more speedup:
$ time docker run -h db2server --name db2server --restart=always --privileged=true -p 50000:50000 --env-file env_list_faster.txt -v D:/db2-community/database:/database icr.io/db2_community/db2 2>&1 | grep -m1 "Setup has completed"
(*) Setup has completed.
real 0m39.585s
user 0m0.015s
sys 0m0.046s
But even that is quite slow, and also doesn't really fit the testcontainers philosophy of creating a new isolated throwaway container from scratch.
For comparison, on the same machine, a MariaDB docker
containers starts up in 6 seconds, and PostgreSQL starts up in less than 2 seconds.
Kind regards,
Jimmy