title: Connecting PostgreSQL installed in docker inside Hyper-V Ubuntu from Windows 10 PgAdmin
body: <p>I need help in connecting PostgreSQL which is installed in Docker inside HyperV ubuntu 18.4 from Windows 10 PgAdmin. So far I tried the following</p>
  
  <p>Step 1: Install Postgres in Docker (Ubuntu running on Hyper-V)</p>
  
  <pre><code>sudo docker run -p 5432:5432 --name pg_test -e POSTGRES_PASSWORD=admin -d postgres
  </code></pre>
  
  <p>Step 2: Create a database </p>
  
  <pre><code>docker exec -it pg_test bash
  psql -U postgres
  create database mytestdb
  </code></pre>
  
  <p>Step 3: Get the ip address</p>
  
  <pre><code>sudo docker inspect pg_test | grep IPAddress
  //returned with 172.17.0.2
  </code></pre>
  
  <p>Step 4: pg_hba.conf</p>
  
  <pre><code>host    all             all             0.0.0.0/0               md5
  </code></pre>
  
  <p>Step 5: When I try to connect from Windows PgAdmin 4, I get this below error -
  <strong>Note</strong>: I have also tried using UBUNTU VM IP address, but no luck
  <a href="https://i.stack.imgur.com/aHXrT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aHXrT.png" alt="enter image description here"></a></p>