<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Brock Balducci</title>
    <description>The latest articles on DEV Community by Brock Balducci (@devbrock).</description>
    <link>https://dev.to/devbrock</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F338419%2Fbb1afe98-2cdc-4701-b5fe-47d7313ed566.jpeg</url>
      <title>DEV Community: Brock Balducci</title>
      <link>https://dev.to/devbrock</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devbrock"/>
    <language>en</language>
    <item>
      <title>How to run PostgreSQL inside of a Docker container in less than 5 minutes!</title>
      <dc:creator>Brock Balducci</dc:creator>
      <pubDate>Tue, 08 Feb 2022 20:51:56 +0000</pubDate>
      <link>https://dev.to/devbrock/how-to-run-postgresql-inside-of-a-docker-container-in-less-than-5-minutes-1hog</link>
      <guid>https://dev.to/devbrock/how-to-run-postgresql-inside-of-a-docker-container-in-less-than-5-minutes-1hog</guid>
      <description>&lt;p&gt;If you are looking for a fast, easy and convenient way to run PostgreSQL and be able to access it via command line or SQL client - this is the perfect solution!&lt;/p&gt;

&lt;p&gt;To start, make sure you have docker installed and that it is running on your machine. To do this run the following command in the command line: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker -v&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, you need to pull down the postgres image from docker hub. You can find the official postgres image &lt;a href="https://hub.docker.com/_/postgres"&gt;here&lt;/a&gt;, if you need to run a specific version of postgres make sure to checkout the available tags.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker pull postgres&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;if you are using a tag run the following command with the tag.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker pull postgres:tag&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Finally, we need to actually run the container. To do this, we need to pass a few flags in our next command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run --name postgres-example -d -p 2022:5432 -e POSTGRES_PASSWORD=postgres postgres&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;name&lt;/strong&gt; will be the name of the container&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-d&lt;/strong&gt; specifies that we want to run the container in detached mode&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-p&lt;/strong&gt; specifies what local port we want mapped to our exposed container port&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-e&lt;/strong&gt; provides the password environment variable to our container&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;postgres&lt;/strong&gt; is the name of the image we want to run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After this, you should be able to run a &lt;code&gt;docker ps&lt;/code&gt; command to see the container running, or head over to your docker desktop application to interact with it there. &lt;/p&gt;

&lt;p&gt;Now you can add this connection to your local sql client or use the CLI for your container to interact with postgres using psql.&lt;/p&gt;

&lt;p&gt;Check out my &lt;a href="https://youtu.be/TfJ8YD7sfsI"&gt;video guide&lt;/a&gt; for more details&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>docker</category>
      <category>database</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
