postgresql-container
postgresql-container copied to clipboard
Creating a new image with default data
HI, We have some bootstrap data that we would like to have the container always have at a minimum.
Is there a way to modify the image so that it can retain this initial datafill?
Commit does not seem to work .
thanks Mike
help .... the container seems to always re-initialize the DB
Hi Mike,
I do not think this specific use case is properly documented but you can certainly do that with s2i. You just need to provide the initial data and a custom assemble script that loads in the data when creating the image with s2i.
For an actual example on how to do this you can check out this test case: https://github.com/sclorg/postgresql-container/blob/master/test/run_test#L711
I am not really familiar with s2i. I will take a look.
I really was hoping for an easy way to just add my PostgreSQL data directory and stop the container startup from wiping it out.
Thanks so much for the reply
On Tue, Jul 31, 2018 at 3:10 AM, Petr Kubat [email protected] wrote:
Hi Mike,
I do not think this specific use case is properly documented but you can certainly do that with s2i. You just need to provide the initial data and a custom assemble script that loads in the data when creating the image with s2i.
For an actual example on how to do this you can check out this test case: https://github.com/sclorg/postgresql-container/blob/ master/test/run_test#L711
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sclorg/postgresql-container/issues/285#issuecomment-409118886, or mute the thread https://github.com/notifications/unsubscribe-auth/AIswnBGxMELF2jqTF49wBQ1R-BG2SO6kks5uMALLgaJpZM4Vkib9 .
As for why docker commit
did not work for you I think this is caused by the use of the VOLUME
command in our dockerfiles. Docker likely does not include any volumes it creates into the image when the container gets committed.
Yes ... you are correct. Is there an easy way to mv (ADD) the PostgreSQL PGDATA directory and contents into the container through a Dockerfile and stop the default startup of this from replacing the contents ?
Thanks so much for your help
On Wed, Aug 1, 2018 at 2:59 AM, Petr Kubat [email protected] wrote:
As for why docker commit did not work for you I think this is caused by the use of the VOLUME command in our dockerfiles. Docker likely does not include any volumes it creates into the image when the container gets committed.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sclorg/postgresql-container/issues/285#issuecomment-409470558, or mute the thread https://github.com/notifications/unsubscribe-auth/AIswnLmxsEzb3uZcwLI69wdViFC8gr3Gks5uMVHFgaJpZM4Vkib9 .
If you are running on OpenShift, the easiest thing is to use the s2i as @pkubatrh mentioned above (maybe look at slightly clearer link to example s2i app).
If s2i is not what you want, create the Dockerfile manually... Then in Dockerfile COPY
the data directory somewhere else then /var/lib/pgsql/data
, and move it on place by CMD
at container startup.
Thanks Pavel,
I guess it's not clear, or I did not find what I need to do to the centos/postgresql-96-centos7 image to execute the s2i hook.
On Thu, Aug 2, 2018 at 1:32 AM, Pavel Raiskup [email protected] wrote:
If you are running on OpenShift, the easiest thing is to use the s2i as @pkubatrh https://github.com/pkubatrh mentioned above (maybe look at slightly clearer link to example s2i app https://github.com/sclorg/postgresql-container/tree/master/examples/s2i-dump-data ).
If s2i is not what you want, create the Dockerfile manually... Then in Dockerfile COPY the data directory somewhere else then /var/lib/pgsql/data, and move it on place by CMD at container startup.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sclorg/postgresql-container/issues/285#issuecomment-409810727, or mute the thread https://github.com/notifications/unsubscribe-auth/AIswnMtzbRlu54peRT67eQdMs1Wj6dE5ks5uMo7ugaJpZM4Vkib9 .
Hmmm ... I tried using the Dockerfile and CMD to move the data dir ... it works I think .... but the container exits after the CMD to move
On Thu, Aug 2, 2018 at 1:32 AM, Pavel Raiskup [email protected] wrote:
If you are running on OpenShift, the easiest thing is to use the s2i as @pkubatrh https://github.com/pkubatrh mentioned above (maybe look at slightly clearer link to example s2i app https://github.com/sclorg/postgresql-container/tree/master/examples/s2i-dump-data ).
If s2i is not what you want, create the Dockerfile manually... Then in Dockerfile COPY the data directory somewhere else then /var/lib/pgsql/data, and move it on place by CMD at container startup.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sclorg/postgresql-container/issues/285#issuecomment-409810727, or mute the thread https://github.com/notifications/unsubscribe-auth/AIswnMtzbRlu54peRT67eQdMs1Wj6dE5ks5uMo7ugaJpZM4Vkib9 .
On Thursday, August 2, 2018 3:43:45 PM CEST Mike wrote:
I guess it's not clear, or I did not find what I need to do to the centos/postgresql-96-centos7 image to execute the s2i hook.
Take a look at s2i page homepage (plain docker): https://github.com/openshift/source-to-image
Or at OpenShift documentation (OpenShift use-case): https://github.com/openshift/source-to-image
Note to myself, we should add README
into https://github.com/sclorg/postgresql-container/tree/master/examples/s2i-dump-data (at least) explaining the basic "howto".