1

I am trying to build docker image with postgres data included.I am following below link.

https://sharmank.medium.com/build-postgres-docker-image-with-data-included-489bd58a1f9e

It is built with data as below.

REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
db_image_with_data                              latest              48b5d776e7d6        2 hours ago        1.67GB

I could see data is available in images using below command


docker run --env PGDATA=postgres -p 5432:5432 -I db_image_with_data

I have pushed same image to docker hub and I have configured same image in kubernets .

But only db has created there is no data populated in db.

kubectl exec my-database-7c4bb7bdd7-m8sjd -n dev-app -- sh -c 'psql -U "postgres" -d "devapp" -c "select * from execution_groups"'
 id | groupname | grouptype | user_id | tag | created_at | updated_at | group_id 
----+-----------+-----------+---------+--------+------------+------------+----------
(0 rows)

Is there anything i am missing out here?

1 Answer 1

1

In the many years since that post came out, it looks like the postgres community container image has been tweaked to automatically provision a volume for the data when running under Docker (via the VOLUME directive). This means your content was stored outside the running container and thus is not part of the saved image. AFAIK this cannot be disabled so you'll have to build your own base image (or find another one to use).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.