I have the following Dockerfile
FROM postgres:9.6.18
ENV POSTGRES_PASSWORD postgres
ENV POSTGRES_DB import
COPY docker/admin-db/*.sql /docker-entrypoint-initdb.d/
This works fine, but every time I buiLD and startup my cluster (docker-compose, combined with an api container) it takes about 2 minutes to load all the sql files (it contains test data). This is not very agile, so I would like to load the data on image creation, not when I am starting the container. As the database image will not change frequently, loading the data during image creation, will most of the time be taken from the cached layers.
How can I start the container during image creation, so the data does not need to be loaded during container start every time I run docker-build?