title: Initialize PostgreSQL in Docker
body: <p>I have an application that populates the database at startup. if I run the application with <strong>docker-compose up</strong>, everything is fine, but if I want to run each single images manually I cannot populate the database, I get a long list of exceptions.  This is a part of:</p>
  
  <pre><code>Microsoft.EntityFrameworkCore.Infrastructure[10403]
    Entity Framework Core 2.0.1-rtm-125 initialized 'ConfigurationDbContext' 
  using provider 'Npgsql.EntityFrameworkCore.PostgreSQL' with options: 
  MigrationsAssembly=Entities
  Application startup exception: 
  System.Net.Internals.SocketExceptionFactory+ExtendedSocketException 
  (0x00000001): Resource temporarily unavailable
  at System.Net.Dns.InternalGetHostByName(String hostName, Boolean 
  includeIPv6)
  at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
  at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
  at Npgsql.NpgsqlConnector.&lt;RawOpen&gt;d__139.MoveNext() 
  </code></pre>
  
  <p>This is part of my docker-compose.yml:</p>
  
  <pre><code>postgres:
    image: postgres
    environment:
      POSTGRES_USER: xxxx
      POSTGRES_PASSWORD: "xxxx"
  
    ports:
      - "8001:5432" 
    restart: always
    networks: 
    - my-network
  </code></pre>