{"id":2613,"date":"2026-01-05T06:00:00","date_gmt":"2026-01-05T14:00:00","guid":{"rendered":"https:\/\/www.virendrachandak.com\/techtalk\/?p=2613"},"modified":"2026-01-05T11:43:50","modified_gmt":"2026-01-05T19:43:50","slug":"postgresql-18-docker-upgrade-dump-and-restore-method","status":"publish","type":"post","link":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/","title":{"rendered":"PostgreSQL 18 Docker Upgrade: Dump and Restore Method"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">PostgreSQL 18 introduces a major change to the official Docker image layout. The internal data directory is now version\u2011specific, which means you cannot simply switch your image tag from <code>postgres:17<\/code> to <code>postgres:18<\/code> and expect your existing volume to work. This guide walks you through a clean and reliable upgrade using the <strong>dump and restore<\/strong> method.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">What Changed in PostgreSQL 18?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Starting with PostgreSQL 18, the official Docker image uses a <strong>new PGDATA structure<\/strong>: (<a href=\"https:\/\/github.com\/docker-library\/postgres\/pull\/1259\" target=\"_blank\" rel=\"noopener\">more info<\/a>).<\/p>\n\n\n\n<figure class=\"wp-block-flexible-table-block-table is-style-default\"><table class=\"has-fixed-layout\"><thead><tr><th>PostgreSQL Version<\/th><th>Default PGDATA Path<\/th><th>Docker VOLUME<\/th><\/tr><\/thead><tbody><tr><td>17 and earlier<\/td><td><code>\/var\/lib\/postgresql\/data<\/code><\/td><td><code>\/var\/lib\/postgresql\/data<\/code><\/td><\/tr><tr><td>18 and later<\/td><td><code>\/var\/lib\/postgresql\/18\/docker<\/code><\/td><td><code>\/var\/lib\/postgresql<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This change will make it easier for future major upgrades. By mounting the parent directory, future images can simply create a new sibling folder (e.g., <code>\/var\/lib\/postgresql\/19\/docker<\/code>). This allows the <code>pg_upgrade<\/code> utility to use the <code>--link<\/code> flag, which performs a nearly instantaneous migration by hard-linking files between versioned directories rather than copying data across volumes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, this change means we cannot use the data in the old <code>\/var\/lib\/postgresql\/data<\/code> path and need to migrate it to the new <code>\/var\/lib\/postgresql<\/code> path. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To successfully move from PostgreSQL 17 to 18, we need to do a standard &#8220;dump and restore&#8221; or use a specialized upgrade container while simultaneously updating your docker-compose.yml to reflect these new path requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The simultaneously upgrading Docker and running multiple versions is more involved process. The easiest is the &#8220;dump and restore&#8221; approach and this article will concentrate on it. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step by step guide to upgrade from Postgres 17 to 18 using dump and restore method<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s start with the sample existing&nbsp;docker-compose.yml&nbsp;for our PostgreSQL 17 instance.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"YAML\" data-shcb-language-slug=\"yaml\"><span><code class=\"hljs language-yaml\"><span class=\"hljs-attr\">services:<\/span>\n  <span class=\"hljs-attr\">db:<\/span>\n    <span class=\"hljs-attr\">image:<\/span> <span class=\"hljs-string\">postgres:17<\/span>\n    <span class=\"hljs-attr\">restart:<\/span> <span class=\"hljs-string\">unless-stopped<\/span>\n    <span class=\"hljs-attr\">environment:<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">POSTGRES_USER=example_user<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">POSTGRES_PASSWORD=example_password<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">POSTGRES_DB=example_db<\/span>\n    <span class=\"hljs-attr\">ports:<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">\"5432:5432\"<\/span>\n    <span class=\"hljs-attr\">volumes:<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">.\/db:\/var\/lib\/postgresql\/data<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">YAML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">yaml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Here is the error message that you might see if you just change the <code>image: postgres:17<\/code> to <code class=\"language-yaml\">image: postgres:18<\/code> in the above docker-compose file and restart.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Error: in 18+, these Docker images are configured to store database data in a format which is compatible with \"pg_ctlcluster\" (specifically, using major-version-specific directory names). &amp;nbsp;This better reflects how PostgreSQL itself works, and how upgrades are to be performed.<br \/><br \/>See also <a href=\"https:\/\/github.com\/docker-library\/postgres\/pull\/1259\u2060\">https:\/\/github.com\/docker-library\/postgres\/pull\/1259\u2060<\/a><br \/><br \/>Counter to that, there appears to be PostgreSQL data in: \/var\/lib\/postgresql\/data (unused mount\/volume) This is usually the result of upgrading the Docker image without upgrading the underlying database using \"pg_upgrade\" (which requires both versions).<br \/><br \/>The suggested container configuration for 18+ is to place a single mount at \/var\/lib\/postgresql which will then place PostgreSQL data in a subdirectory, allowing usage of \"pg_upgrade --link\" without mount point boundary issues.<br \/><br \/>See <a href=\"https:\/\/github.com\/docker-library\/postgres\/issues\/37\">https:\/\/github.com\/docker-library\/postgres\/issues\/37<\/a>\u2060 for a (long) discussion around this process, and suggestions for how to do so.<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Review the postgres compatibility<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Read the&nbsp;<a href=\"https:\/\/www.postgresql.org\/docs\/18\/release-18.html\">PostgreSQL 18 release notes<\/a>&nbsp;for any breaking changes and confirm that all extensions, application drivers and tools you use are compatible with PostgreSQL 18. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Always make sure to test the changes in a staging environment before performing it on a production system and always having a solid backup and rollback plan.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Export the current data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We will export the data from the old version and then restore in the new version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can use the following command to export. Make sure to change the container name (pg17_container) to your container name<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker <span class=\"hljs-built_in\">exec<\/span> -t pg17_container pg_dumpall -U example_user &gt; backup.sql<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Once the backup is created verify the backup.sql file is not empty and contains the schema and data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Stop the old container<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">With the backup secured, you can safely shut down the old container. It&#8217;s also best practice to rename the old data volume directory. This prevents the new PostgreSQL 18 instance from accidentally trying to use the old, incompatible data files.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker compose down\nmv .\/db .\/db-old<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"step-3-update-docker-composeyml-for-postgresql-18\">Step 4: Update docker-compose.yml&nbsp;for PostgreSQL 18<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now, modify your&nbsp;<code>docker-compose.yml<\/code>&nbsp;file. You need to update the image tag to&nbsp;<code>postgres:18<\/code>&nbsp;and, most importantly,&nbsp;<strong>update the volume path<\/strong>&nbsp;to reflect the new version-specific directory structure used by the official image.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"YAML\" data-shcb-language-slug=\"yaml\"><span><code class=\"hljs language-yaml\"><span class=\"hljs-attr\">services:<\/span>\n  <span class=\"hljs-attr\">db:<\/span>\n    <span class=\"hljs-attr\">image:<\/span> <span class=\"hljs-string\">postgres:18<\/span> <span class=\"hljs-comment\"># Change version number<\/span>\n    <span class=\"hljs-attr\">restart:<\/span> <span class=\"hljs-string\">unless-stopped<\/span>\n    <span class=\"hljs-attr\">environment:<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">POSTGRES_USER=example_user<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">POSTGRES_PASSWORD=example_password<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">POSTGRES_DB=example_db<\/span>\n    <span class=\"hljs-attr\">ports:<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">\"5432:5432\"<\/span>\n    <span class=\"hljs-attr\">volumes:<\/span>\n      <span class=\"hljs-comment\"># IMPORTANT: The PGDATA path is now version-specific<\/span>\n      <span class=\"hljs-bullet\">-<\/span> <span class=\"hljs-string\">.\/db:\/var\/lib\/postgresql<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">YAML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">yaml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">Do <strong>not<\/strong> set <code>PGDATA=\/var\/lib\/postgresql\/data<\/code> in PostgreSQL 18. The new image manages versioned directories automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-4-start-the-new-container\">Step 5: Start the New Container<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s time to bring up the new PostgreSQL 18 container. Docker Compose will pull the&nbsp;<code>postgres:18<\/code>&nbsp;image and create a new, empty&nbsp;<code>.\/db<\/code>&nbsp;directory on your host, which will be used to initialize the new database instance.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker compose up -d<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"step-5-restore-your-data\">Step 6: Restore Your Data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once the new container is up and running, you can restore your data from the backup file created in Step 1. We will pipe the&nbsp;<code>backup.sql<\/code>&nbsp;file into the&nbsp;<code>psql<\/code>&nbsp;command inside the new container (pg18_container).<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker <span class=\"hljs-built_in\">exec<\/span> -i pg18_container psql -U example_user -d example_db &lt; backup.sql<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">This command may take some time, depending on the size of your database.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-7-check-the-version\">Step 7: Check the Version<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As a final confirmation, you can execute a command inside the container to check the running PostgreSQL version.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker <span class=\"hljs-built_in\">exec<\/span> -it pg18_container psql -U example_user -d example_db<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">After connecting, run the following SQL query:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">version<\/span>();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">You should see an output confirming you are now running PostgreSQL 18.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"step-6-clean-up-optional\">Step 8: Clean Up (Optional)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After the restore process finishes, connect to your database with your application or a database client to ensure all data has been restored correctly. Once you have fully verified the integrity of the migration, you can safely remove the old data directory and the SQL backup file to reclaim disk space.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">rm -rf .\/db-old\nrm backup.sql<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Limitations of dump and restore method<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">While this method is simple and reliable, it has drawbacks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Downtime<\/strong> is required<\/li>\n\n\n\n<li><strong>Slow for large databases<\/strong> (100GB+)<\/li>\n\n\n\n<li><strong>Indexes must be rebuilt<\/strong>, increasing restore time<\/li>\n\n\n\n<li><strong>High CPU usage<\/strong> during restore<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For large production databases, consider using <strong>pg_upgrade<\/strong> instead. PostgreSQL 18 improves <code>pg_upgrade<\/code> with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Faster parallel checks (<code>--jobs<\/code>)<\/li>\n\n\n\n<li>Hard\u2011linking support<\/li>\n\n\n\n<li>Faster directory switching (<code>--swap<\/code>)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PostgreSQL 18 introduces a new version\u2011specific data directory that breaks old Docker volumes. This guide shows how to upgrade from PostgreSQL 17 to 18 using a clean dump\u2011and\u2011restore workflow.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[172],"tags":[173],"class_list":["post-2613","post","type-post","status-publish","format-standard","hentry","category-postgressql","tag-postgresql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL 18 Docker Upgrade: Dump and Restore Method - Virendra&#039;s TechTalk<\/title>\n<meta name=\"description\" content=\"PostgreSQL 18 introduces a new version\u2011specific data directory that breaks old Docker volumes. This guide shows how to upgrade from PostgreSQL 17 to 18 using a clean dump\u2011and\u2011restore workflow.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL 18 Docker Upgrade: Dump and Restore Method - Virendra&#039;s TechTalk\" \/>\n<meta property=\"og:description\" content=\"PostgreSQL 18 introduces a new version\u2011specific data directory that breaks old Docker volumes. This guide shows how to upgrade from PostgreSQL 17 to 18 using a clean dump\u2011and\u2011restore workflow.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/\" \/>\n<meta property=\"og:site_name\" content=\"Virendra&#039;s TechTalk\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/virendrachandak\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/virendrachandak\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-05T14:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-05T19:43:50+00:00\" \/>\n<meta name=\"author\" content=\"Virendra Chandak\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@virendrachandak\" \/>\n<meta name=\"twitter:site\" content=\"@virendrachandak\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virendra Chandak\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/\"},\"author\":{\"name\":\"Virendra Chandak\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\"},\"headline\":\"PostgreSQL 18 Docker Upgrade: Dump and Restore Method\",\"datePublished\":\"2026-01-05T14:00:00+00:00\",\"dateModified\":\"2026-01-05T19:43:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/\"},\"wordCount\":745,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\"},\"keywords\":[\"PostgreSQL\"],\"articleSection\":[\"PostgresSQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/\",\"url\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/\",\"name\":\"PostgreSQL 18 Docker Upgrade: Dump and Restore Method - Virendra&#039;s TechTalk\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#website\"},\"datePublished\":\"2026-01-05T14:00:00+00:00\",\"dateModified\":\"2026-01-05T19:43:50+00:00\",\"description\":\"PostgreSQL 18 introduces a new version\u2011specific data directory that breaks old Docker volumes. This guide shows how to upgrade from PostgreSQL 17 to 18 using a clean dump\u2011and\u2011restore workflow.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/postgresql-18-docker-upgrade-dump-and-restore-method\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"TechTalk\",\"item\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgresSQL\",\"item\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/category\\\/postgressql\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL 18 Docker Upgrade: Dump and Restore Method\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#website\",\"url\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/\",\"name\":\"Virendra's TechTalk\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/63f7ffa1ea125e32af9618d188349e17\",\"name\":\"Virendra Chandak\",\"logo\":{\"@id\":\"https:\\\/\\\/www.virendrachandak.com\\\/techtalk\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.virendrachandak.com\",\"https:\\\/\\\/www.facebook.com\\\/virendrachandak\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/virendrachandak\\\/\",\"https:\\\/\\\/x.com\\\/virendrachandak\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL 18 Docker Upgrade: Dump and Restore Method - Virendra&#039;s TechTalk","description":"PostgreSQL 18 introduces a new version\u2011specific data directory that breaks old Docker volumes. This guide shows how to upgrade from PostgreSQL 17 to 18 using a clean dump\u2011and\u2011restore workflow.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL 18 Docker Upgrade: Dump and Restore Method - Virendra&#039;s TechTalk","og_description":"PostgreSQL 18 introduces a new version\u2011specific data directory that breaks old Docker volumes. This guide shows how to upgrade from PostgreSQL 17 to 18 using a clean dump\u2011and\u2011restore workflow.","og_url":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/","og_site_name":"Virendra&#039;s TechTalk","article_publisher":"https:\/\/www.facebook.com\/virendrachandak","article_author":"https:\/\/www.facebook.com\/virendrachandak","article_published_time":"2026-01-05T14:00:00+00:00","article_modified_time":"2026-01-05T19:43:50+00:00","author":"Virendra Chandak","twitter_card":"summary_large_image","twitter_creator":"@virendrachandak","twitter_site":"@virendrachandak","twitter_misc":{"Written by":"Virendra Chandak","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/#article","isPartOf":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/"},"author":{"name":"Virendra Chandak","@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17"},"headline":"PostgreSQL 18 Docker Upgrade: Dump and Restore Method","datePublished":"2026-01-05T14:00:00+00:00","dateModified":"2026-01-05T19:43:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/"},"wordCount":745,"commentCount":0,"publisher":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17"},"keywords":["PostgreSQL"],"articleSection":["PostgresSQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/","url":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/","name":"PostgreSQL 18 Docker Upgrade: Dump and Restore Method - Virendra&#039;s TechTalk","isPartOf":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#website"},"datePublished":"2026-01-05T14:00:00+00:00","dateModified":"2026-01-05T19:43:50+00:00","description":"PostgreSQL 18 introduces a new version\u2011specific data directory that breaks old Docker volumes. This guide shows how to upgrade from PostgreSQL 17 to 18 using a clean dump\u2011and\u2011restore workflow.","breadcrumb":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.virendrachandak.com\/techtalk\/postgresql-18-docker-upgrade-dump-and-restore-method\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"TechTalk","item":"https:\/\/www.virendrachandak.com\/techtalk\/"},{"@type":"ListItem","position":2,"name":"PostgresSQL","item":"https:\/\/www.virendrachandak.com\/techtalk\/category\/postgressql\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL 18 Docker Upgrade: Dump and Restore Method"}]},{"@type":"WebSite","@id":"https:\/\/www.virendrachandak.com\/techtalk\/#website","url":"https:\/\/www.virendrachandak.com\/techtalk\/","name":"Virendra's TechTalk","description":"","publisher":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.virendrachandak.com\/techtalk\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/63f7ffa1ea125e32af9618d188349e17","name":"Virendra Chandak","logo":{"@id":"https:\/\/www.virendrachandak.com\/techtalk\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/www.virendrachandak.com","https:\/\/www.facebook.com\/virendrachandak","https:\/\/www.linkedin.com\/in\/virendrachandak\/","https:\/\/x.com\/virendrachandak"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2vTtQ-G9","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":2769,"url":"https:\/\/www.virendrachandak.com\/techtalk\/what-is-clickhouse\/","url_meta":{"origin":2613,"position":0},"title":"What Is ClickHouse, and When Should You Use It?","author":"Virendra Chandak","date":"July 21, 2026","format":false,"excerpt":"ClickHouse is an open-source columnar database built for analytics at massive scale: fast aggregation and filtering over very large datasets. ClickHouse may look like a relational database, but it\u2019s engineered for a fundamentally different purpose than Postgres or MySQL, and treating it as a drop-in replacement is the most common\u2026","rel":"","context":"In &quot;Clickhouse&quot;","block_context":{"text":"Clickhouse","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/clickhouse\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2762,"url":"https:\/\/www.virendrachandak.com\/techtalk\/clickhouse-for-mysql-developers\/","url_meta":{"origin":2613,"position":1},"title":"ClickHouse for MySQL Developers: What&#8217;s Different and Why","author":"Virendra Chandak","date":"August 18, 2026","format":false,"excerpt":"ClickHouse uses SQL and looks familiar, but it is not \"MySQL but faster.\" What a MySQL developer needs to know before using it \u2014 columnar storage, no enforced primary key, append-only writes, batch inserts, and denormalized joins \u2014 with runnable Docker examples.","rel":"","context":"In &quot;Clickhouse&quot;","block_context":{"text":"Clickhouse","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/clickhouse\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1045,"url":"https:\/\/www.virendrachandak.com\/techtalk\/how-to-find-and-replace-data-in-mysql\/","url_meta":{"origin":2613,"position":2},"title":"How to Find and Replace Data in MySQL","author":"Virendra Chandak","date":"August 5, 2012","format":false,"excerpt":"Recently, while migrating my blog, I had to find all the occurrences of my old URL and replace it with my URL. One way of doing this was to get a database dump, open it in a text editor and the do a find replace and the import it back.\u2026","rel":"","context":"In &quot;MySQL&quot;","block_context":{"text":"MySQL","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/mysql\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1131,"url":"https:\/\/www.virendrachandak.com\/techtalk\/how-to-remove-wordpress-version-number\/","url_meta":{"origin":2613,"position":3},"title":"How to remove WordPress version number","author":"Virendra Chandak","date":"August 19, 2012","format":false,"excerpt":"By default WordPress adds a meta tag which displays the WordPress version number that your WordPress site is running on. The version number is added just for tracking. This information can be useful to hacker to identify which version of WordPress you are running. If you are not running the\u2026","rel":"","context":"In &quot;WordPress&quot;","block_context":{"text":"WordPress","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/wordpress\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":224,"url":"https:\/\/www.virendrachandak.com\/techtalk\/htaccess-tips\/","url_meta":{"origin":2613,"position":4},"title":".htaccess tips","author":"Virendra Chandak","date":"October 2, 2011","format":false,"excerpt":"Topics Covered: What is .htaccess file? When to use .htaccess file? Disadvantage of using .htaccess file Authentication using .htaccess file Custom Error Document Allow\/Disallow Directory Listings What is .htaccess file? .htaccess file is used on Apache Web Server to make configuration changes on per-directory basis. This file contains the configuration\u2026","rel":"","context":"In &quot;Server Configuration&quot;","block_context":{"text":"Server Configuration","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/server-configuration\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":255,"url":"https:\/\/www.virendrachandak.com\/techtalk\/more-htaccess-tips\/","url_meta":{"origin":2613,"position":5},"title":"more .htaccess tips","author":"Virendra Chandak","date":"October 16, 2011","format":false,"excerpt":"In my previous post .htaccess tips I had started with what is .htaccess file and some things that can be done using it. In this post I'll cover more about .htaccess files. Topics Covered: Directory index file Redirection Preferred domain (www or non-www) Redirect old site to new site Redirect\u2026","rel":"","context":"In &quot;Server Configuration&quot;","block_context":{"text":"Server Configuration","link":"https:\/\/www.virendrachandak.com\/techtalk\/category\/server-configuration\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts\/2613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/comments?post=2613"}],"version-history":[{"count":119,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts\/2613\/revisions"}],"predecessor-version":[{"id":2754,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/posts\/2613\/revisions\/2754"}],"wp:attachment":[{"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/media?parent=2613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/categories?post=2613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virendrachandak.com\/techtalk\/wp-json\/wp\/v2\/tags?post=2613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}