{"id":122088,"date":"2024-01-02T11:11:30","date_gmt":"2024-01-02T09:11:30","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=122088"},"modified":"2024-01-02T11:11:32","modified_gmt":"2024-01-02T09:11:32","slug":"docker-running-postgresql-as-a-container","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/","title":{"rendered":"Docker \u2013 Running PostgreSQL as a container"},"content":{"rendered":"<p>Docker simplifies database management, ensuring consistency across environments. Let us delve into a practical approach to understanding the management of PostgreSQL in a Docker container.<\/p>\n<h2><a name=\"introduction\"><\/a>1. Introduction<\/h2>\n<p><a href=\"https:\/\/www.docker.com\/\" target=\"_blank\" rel=\"noopener\">Docker<\/a> is an open-source platform used for the containerization of applications. It allows developers to package their applications along with their dependencies, libraries, and other necessary components into a single container that can run reliably and consistently on any platform. The containerization technology provided by Docker ensures that the application behaves the same way regardless of the underlying infrastructure. Some benefits of Docker are:<\/p>\n<ul>\n<li>Portability: Docker containers can run on any platform, regardless of the underlying infrastructure. This makes it easy to move applications between development, testing, and production environments.<\/li>\n<li>Scalability: Docker allows you to quickly and easily scale your application by adding or removing containers as needed, without having to make changes to the underlying infrastructure.<\/li>\n<li>Isolation: Docker provides a high level of isolation between applications, ensuring that each container runs independently of others, without interfering with each other.<\/li>\n<li>Efficiency: Docker containers are lightweight and efficient, consuming fewer resources than traditional virtual machines. This allows you to run more applications on the same hardware.<\/li>\n<li>Consistency: Docker ensures that applications behave the same way across different environments, making it easier to test and deploy new versions of your application.<\/li>\n<li>Security: Docker provides built-in security features that help protect your applications from external threats. Docker containers are isolated from each other and the underlying infrastructure, reducing the risk of attacks.<\/li>\n<\/ul>\n<p>If someone needs to go through the Docker installation, please watch <a href=\"https:\/\/www.youtube.com\/watch?v=R-ZMkGvh-9Y\" target=\"_blank\" rel=\"noopener\">this<\/a> video.<\/p>\n<h2>2. PostgreSQL in a Docker container<\/h2>\n<p>To set up <a href=\"https:\/\/hub.docker.com\/_\/postgres\" target=\"_blank\" rel=\"noopener\">PostgreSQL<\/a> in Docker we will be making use of the <code>docker-compose.yml<\/code> file. A <em>Docker Compose YML file<\/em> is a configuration file that defines how Docker containers should behave when started as part of a multi-container application. It specifies services, networks, and volumes, along with their settings and relationships, simplifying the deployment and management of interconnected Docker containers.<\/p>\n<h3>2.1 Creating and Starting the Container<\/h3>\n<p>Let us break down the key components of the Docker Compose file (<code>postgresql-docker-compose.yml<\/code>) that will enable you to deploy a PostgreSQL container with specified configurations and persistent data storage.<\/p>\n<ul>\n<li>Version: The <code>version: '3.8'<\/code> indicates the version of the Docker Compose file syntax being used.<\/li>\n<li>Services: The <code>services<\/code> section defines the containers that make up the application.\n<ul>\n<li><code>image: postgres:latest<\/code>: Specifies the Docker image to be used (latest version of PostgreSQL).<\/li>\n<li><code>container_name: my-postgres-container<\/code>: Assign a custom name to the PostgreSQL container.<\/li>\n<li><code>restart: no<\/code>: Specifies that the container should not automatically restart.<\/li>\n<li><code>environment<\/code>: Sets environment variables for PostgreSQL, including user, password, and database.<\/li>\n<li><code>ports: - \"5445:5432\"<\/code>: Maps port 5445 on the host to port 5432 on the PostgreSQL container.<\/li>\n<li><code>volumes: - postgres_data:\/var\/lib\/postgresql\/data<\/code>: Mounts a volume named <code>postgres_data<\/code> to persist PostgreSQL data.<\/li>\n<\/ul>\n<\/li>\n<li>Volumes: The <code>volumes<\/code> section defines named volumes used by the services. <code>postgres_data<\/code> is a named volume used to store PostgreSQL data persistently.<\/li>\n<\/ul>\n<pre class=\"brush:plain; wrap-lines:false;\">\nversion: '3.8'\n\nservices:\n  postgres:\n    image: postgres:latest\n    container_name: my-postgres-container\n    restart: no\n    environment:\n      POSTGRES_USER: postgres\n      POSTGRES_PASSWORD: mysecretpassword\n      POSTGRES_DB: welcome\n    ports:\n      - \"5445:5432\"\n    volumes:\n      - postgres_data:\/var\/lib\/postgresql\/data\n\nvolumes:\n  postgres_data:\n<\/pre>\n<h4>2.1.1 Starting the Container<\/h4>\n<p>The <code>docker-compose up<\/code> command will read the configuration file, and create and start the service defined within it. The command will start the postgresql container with the given settings and expose it on a port <code>5445<\/code> of the host system while persisting data in a named volume called <code>postgres_data<\/code>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\ndocker-compose -f postgresql-docker-compose.yml up\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/createandstartpostgresqlcontainerimg1.jpg\"><img decoding=\"async\" width=\"709\" height=\"243\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/createandstartpostgresqlcontainerimg1.jpg\" alt=\"\" class=\"wp-image-122089\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/createandstartpostgresqlcontainerimg1.jpg 709w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/createandstartpostgresqlcontainerimg1-300x103.jpg 300w\" sizes=\"(max-width: 709px) 100vw, 709px\" \/><\/a><figcaption class=\"wp-element-caption\">Fig. 1: Initializing and starting the container<\/figcaption><\/figure>\n<\/div>\n<h4>2.1.2 Verifying the Container<\/h4>\n<p>The <code>docker ps -a<\/code> command will list both running and stopped containers. We will use the <code>filter<\/code> attribute to display the postgresql container.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\ndocker ps -a --filter \"name=my-postgres-container\"\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/verifyingpostgresqlcontainerimg2.jpg\"><img decoding=\"async\" width=\"818\" height=\"57\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/verifyingpostgresqlcontainerimg2.jpg\" alt=\"\" class=\"wp-image-122090\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/verifyingpostgresqlcontainerimg2.jpg 818w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/verifyingpostgresqlcontainerimg2-300x21.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/verifyingpostgresqlcontainerimg2-768x54.jpg 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a><figcaption class=\"wp-element-caption\">Fig. 2: Verifying container<\/figcaption><\/figure>\n<\/div>\n<h3>2.2 Accessing the Container Logs<\/h3>\n<p>The <code>docker-compose logs<\/code> command is useful for troubleshooting, monitoring, or simply observing the activities of the containers defined in the compose configuration. <\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\ndocker-compose -f postgresql-docker-compose.yml logs\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerlogsimg3.jpg\"><img decoding=\"async\" width=\"693\" height=\"353\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerlogsimg3.jpg\" alt=\"\" class=\"wp-image-122091\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerlogsimg3.jpg 693w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerlogsimg3-300x153.jpg 300w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/a><figcaption class=\"wp-element-caption\">Fig. 3: Accessing the container logs<\/figcaption><\/figure>\n<\/div>\n<h3>2.3 Accessing the Container<\/h3>\n<p>The <code>docker exec<\/code> command is useful in running an interactive shell inside the container. This command helps in troubleshooting, inspecting the container\u2019s file system, or running specific commands.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">docker exec -it my-postgres-container bash\n<\/pre>\n<p>Once you\u2019re inside the container we can trigger some sql commands. You can download the SQL scripts from the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerandrunningscriptsimg4.jpg\"><img decoding=\"async\" width=\"818\" height=\"250\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerandrunningscriptsimg4.jpg\" alt=\"\" class=\"wp-image-122092\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerandrunningscriptsimg4.jpg 818w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerandrunningscriptsimg4-300x92.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/accessingpostgresqlcontainerandrunningscriptsimg4-768x235.jpg 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a><figcaption class=\"wp-element-caption\">Fig. 4: Accessing the container and running SQL scripts<\/figcaption><\/figure>\n<\/div>\n<h3>2.4 Stopping the Container<\/h3>\n<p>The <code>docker-compose down<\/code> command is useful to stop the container defined in the compose configuration.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\ndocker-compose -f postgresql-docker-compose.yml stop\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingpostgresqlcontainerimg5.jpg\"><img decoding=\"async\" width=\"705\" height=\"59\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingpostgresqlcontainerimg5.jpg\" alt=\"\" class=\"wp-image-122093\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingpostgresqlcontainerimg5.jpg 705w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingpostgresqlcontainerimg5-300x25.jpg 300w\" sizes=\"(max-width: 705px) 100vw, 705px\" \/><\/a><figcaption class=\"wp-element-caption\">Fig. 5: Stopping the container<\/figcaption><\/figure>\n<\/div>\n<h3>2.5 Re-running the Container<\/h3>\n<p>To re-run the container trigger the <code>docker-compose up<\/code> command.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\ndocker-compose -f postgresql-docker-compose.yml up\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/rerunpostgresqlcontainerimg6.jpg\"><img decoding=\"async\" width=\"818\" height=\"182\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/rerunpostgresqlcontainerimg6.jpg\" alt=\"\" class=\"wp-image-122094\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/rerunpostgresqlcontainerimg6.jpg 818w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/rerunpostgresqlcontainerimg6-300x67.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/rerunpostgresqlcontainerimg6-768x171.jpg 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a><figcaption class=\"wp-element-caption\">Fig. 6: Re-run the container<\/figcaption><\/figure>\n<\/div>\n<h3>2.6 Removing the Container<\/h3>\n<p>The <code>docker-compose down<\/code> command is useful for stopping and removing the containers, networks, and volumes defined in the compose configuration.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">\ndocker-compose -f postgresql-docker-compose.yml down\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingandremovingpostgresqlcontainerimg7.jpg\"><img decoding=\"async\" width=\"700\" height=\"70\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingandremovingpostgresqlcontainerimg7.jpg\" alt=\"\" class=\"wp-image-122095\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingandremovingpostgresqlcontainerimg7.jpg 700w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/stoppingandremovingpostgresqlcontainerimg7-300x30.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><figcaption class=\"wp-element-caption\">Fig. 7: Stopping and removing the container<\/figcaption><\/figure>\n<\/div>\n<h2>3. Conclusion<\/h2>\n<p>In conclusion, leveraging PostgreSQL within a Docker container provides a flexible and efficient solution for database management. Docker&#8217;s containerization technology allows for the encapsulation of the PostgreSQL database, ensuring consistency across various environments and simplifying deployment processes. The ability to define configurations, set up environments, and manage dependencies using a Docker Compose file streamlines the deployment and scaling of PostgreSQL instances. Furthermore, Docker facilitates seamless collaboration by encapsulating the database and its dependencies, reducing compatibility issues. With the added benefit of easy portability, PostgreSQL in a Docker container enhances development workflows, making it a versatile choice for both local development environments and production deployments. The combination of PostgreSQL&#8217;s robust relational database capabilities and Docker&#8217;s containerization brings a powerful and convenient solution to modern database management challenges.<\/p>\n<p>You can download the commands from the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>4. Download the Code<\/h2>\n<p>This was a tutorial to download the commands used in this article.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/PostgreSQL-in-a-Docker-container.zip\"><strong>PostgreSQL in a Docker container<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Docker simplifies database management, ensuring consistency across environments. Let us delve into a practical approach to understanding the management of PostgreSQL in a Docker container. 1. Introduction Docker is an open-source platform used for the containerization of applications. It allows developers to package their applications along with their dependencies, libraries, and other necessary components into &hellip;<\/p>\n","protected":false},"author":119,"featured_media":31013,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1354],"tags":[46870,1276,1319,719],"class_list":["post-122088","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","tag-container","tag-docker","tag-docker-compose","tag-postgresql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Docker \u2013 Running PostgreSQL as a container - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"PostgreSQL in a Docker container: Optimize and streamline setup of PostgreSQL deployment with Docker containers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker \u2013 Running PostgreSQL as a container - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"PostgreSQL in a Docker container: Optimize and streamline setup of PostgreSQL deployment with Docker containers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-02T09:11:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-02T09:11:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"Docker \u2013 Running PostgreSQL as a container\",\"datePublished\":\"2024-01-02T09:11:30+00:00\",\"dateModified\":\"2024-01-02T09:11:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/\"},\"wordCount\":859,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg\",\"keywords\":[\"container\",\"docker\",\"docker-compose\",\"PostgreSQL\"],\"articleSection\":[\"Docker\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/\",\"name\":\"Docker \u2013 Running PostgreSQL as a container - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg\",\"datePublished\":\"2024-01-02T09:11:30+00:00\",\"dateModified\":\"2024-01-02T09:11:32+00:00\",\"description\":\"PostgreSQL in a Docker container: Optimize and streamline setup of PostgreSQL deployment with Docker containers.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DevOps\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/devops\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Docker\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/devops\/docker\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Docker \u2013 Running PostgreSQL as a container\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Docker \u2013 Running PostgreSQL as a container - Java Code Geeks","description":"PostgreSQL in a Docker container: Optimize and streamline setup of PostgreSQL deployment with Docker containers.","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:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/","og_locale":"en_US","og_type":"article","og_title":"Docker \u2013 Running PostgreSQL as a container - Java Code Geeks","og_description":"PostgreSQL in a Docker container: Optimize and streamline setup of PostgreSQL deployment with Docker containers.","og_url":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2024-01-02T09:11:30+00:00","article_modified_time":"2024-01-02T09:11:32+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"Docker \u2013 Running PostgreSQL as a container","datePublished":"2024-01-02T09:11:30+00:00","dateModified":"2024-01-02T09:11:32+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/"},"wordCount":859,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg","keywords":["container","docker","docker-compose","PostgreSQL"],"articleSection":["Docker"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/","url":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/","name":"Docker \u2013 Running PostgreSQL as a container - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg","datePublished":"2024-01-02T09:11:30+00:00","dateModified":"2024-01-02T09:11:32+00:00","description":"PostgreSQL in a Docker container: Optimize and streamline setup of PostgreSQL deployment with Docker containers.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/12\/docker-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/docker-running-postgresql-as-a-container\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"DevOps","item":"https:\/\/examples.javacodegeeks.com\/category\/devops\/"},{"@type":"ListItem","position":3,"name":"Docker","item":"https:\/\/examples.javacodegeeks.com\/category\/devops\/docker\/"},{"@type":"ListItem","position":4,"name":"Docker \u2013 Running PostgreSQL as a container"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/122088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=122088"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/122088\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/31013"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=122088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=122088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=122088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}