title: Cannot get connection between containers
body: <p>I have included the code here..
  <a href="https://github.com/vinceyoumans/achal" rel="nofollow noreferrer">https://github.com/vinceyoumans/achal</a></p>
  <p><strong>PROBLEM:</strong>  Two containers in a docker compose file. one is standard Postgress container.  The second is a goLang Scratch container.  The GoLang main.go file panics when the postgres connection fails. you can see the code on github.</p>
  <h2>The error is:</h2>
  <h3>dial tcp: lookup postgres on 127.0.0.11:53: no such host</h3>
  <p><strong>REQUEST:</strong>
  look over the main.go and dockercompose file to see what is wrong with this network.. what I am missing.</p>
  <h2>main.go</h2>
  <pre><code>db, err := gorm.Open(&quot;postgres&quot;, &quot;host='postgres' port=5432 user=docker dbname='docker' password='password'&quot;)
  
  if err != nil {
      fmt.Println(&quot;============   exiting ==========&quot;)
      fmt.Println(err)
      panic(&quot;failed to connect database e&quot;)
      //  the error i get... dial tcp: lookup postgres on 127.0.0.11:53: no such host
      // panic(&quot;failed to connect database: &quot; + err)
  }
  </code></pre>
  <p>The docker-compose.yml</p>
  <pre><code>version: '3.6'
  services:
    postgre:
      image: postgres:11.1-alpine
      ports:
        - '5432:5432'
      #network_mode: bridge
      #container_name: postgres
   
      environment:
        POSTGRES_USER: 'user'
        POSTGRES_PASSWORD: 'password'
        POSTGRESS_DB: 'db_amex01'
      volumes:
        - ./init:/docker-entrypoint-initdb.d/
  
    todo:
      build: ./go_amex/
      # ports:
      #   - &quot;8000:8080&quot;
  
  # sudo docker-compose -f docker-compose.yml up
  
  #  HELP:  how would I add the goLang service from this point?
  </code></pre>