title: How do I get my app in a docker instance to talk to my database in another docker instance inside the same network?
body: <p>Ok I give up! I spent far too much time on this:</p>
  <p>So I want my app inside a docker container to talk to my postgres which is inside another container.</p>
  <p>Docker-compose.yml</p>
  <pre><code>version: &quot;3.8&quot;
  services:
    foodbudget-db:
      container_name: foodbudget-db
      image: postgres:12.4
      restart: always
      environment:
        POSTGRES_USER: user
        POSTGRES_PASSWORD: pass
        POSTGRES_DB: foodbudget
        PGDATA: /var/lib/postgresql/data
      volumes:
        - ./pgdata:/var/lib/postgresql/data
      ports:
        - 5433:5432
    web:
      image: node:14.10.1
      env_file:
        - .env
      depends_on:
        - foodbudget-db
      ports:
        - 8080:8080
      build:
        context: .
        dockerfile: Dockerfile
  </code></pre>
  <p>Dockerfile</p>
  <pre><code>FROM node:14.10.1
  
  WORKDIR /src/app
  
  ADD https://github.com/palfrey/wait-for-db/releases/download/v1.0.0/wait-for-db-linux-x86 /src/app/wait-for-db
  RUN chmod +x /src/app/wait-for-db
  RUN ./wait-for-db -m postgres -c postgresql://user:pass@foodbudget-db:5433 -t 1000000
  
  EXPOSE 8080
  </code></pre>
  <p>But I keep getting this error when I build the Dockerfile, even though the database is up and running when I run <code>docker ps</code>. I tried connecting to the postgres database in my host machine, and it connected successfully...
  <code>Temporary error (pausing for 3 seconds): PostgresError { error: Error(Io(Custom { kind: Other, error: &quot;failed to lookup address information: Name does not resolve&quot; })) }</code></p>
  <p>Have anyone created an app and talk to a db in another docker instance be4?</p>