I have been trying to make an ODC index database state (products and their corresponding datasets) available (1) as a Docker image - probably kept locally due to its size - or (2) as a Docker volume. I've been restoring databases with compressed SQL files from pg_dump
and I want to avoid pushing images that are 10s of GiB in size.
I tried using docker commit
to implement option #1, and when running a container based on the resulting image, the size of the /var/lib/postgresql/data
directory is the same as in the origin container and datacube system check
perceives the connection to the container to be a valid one - so (1) the connection to the origin container and the container from the image from docker commit
both appear to be valid to an ODC client - with datacube system check
not requesting datacube system init
to be run in either case and (2) have the same amount of data in Postgres (same data directory size).
However, for connections to the origin container, datacube product list
shows the products and ODC queries in Python return the expected results. In contrast, for connections to the derived container (from docker commit
), datacube product list
shows no products and ODC queries perceive there to be no products as well.
I also tried option 2 - creating a Docker volume and using the same Postgres image for both - terminating the origin before launching the other container to use the data in the volume. The results are the same.
The ODC client for the origin and later Postgres containers have the same execution environments - same image, same launch settings - but they are in different docker-compose
environments (that is, the first docker-compose
environment sets up the container with the data, then shuts down, then the second docker-compose
environment starts another Postgres container using the same image).
How should this be done? How can databases be restored and then reused elsewhere as Docker containers?