<p>I am trying to build docker image with postgres data included.I am following below link.</p>
<pre><code>https://sharmank.medium.com/build-postgres-docker-image-with-data-included-489bd58a1f9e
</code></pre>
<p>It is built with data as below.</p>
<pre><code>REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
db_image_with_data                              latest              48b5d776e7d6        2 hours ago        1.67GB

</code></pre>
<p>I could see data is available  in images using below command</p>
<pre><code>
docker run --env PGDATA=postgres -p 5432:5432 -I db_image_with_data

</code></pre>
<p>I have pushed same image to docker hub and I have configured same image in kubernets .</p>
<p>But only db has created there is no data populated in db.</p>
<pre><code>kubectl exec my-database-7c4bb7bdd7-m8sjd -n dev-app -- sh -c 'psql -U &quot;postgres&quot; -d &quot;devapp&quot; -c &quot;select * from execution_groups&quot;'
 id | groupname | grouptype | user_id | tag | created_at | updated_at | group_id 
----+-----------+-----------+---------+--------+------------+------------+----------
(0 rows)

</code></pre>
<p>Is there anything i am missing out here?</p>

<p>In the many years since that post came out, it looks like the <code>postgres</code> community container image has been tweaked to automatically provision a volume for the data when running under Docker (via the <code>VOLUME</code> 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).</p>
