title: Docker lumen app throwing php_network_getaddresses: getaddrinfo failed: Name or service not known
body: <p>I'll start by saying that I am brand new to Docker. I am trying to do a proof of concept for Docker with an existing Lumen microservice but can't seem to get the mysql container on my local to work properly.</p>
  
  <p>When I run php artisan migrate, I get this error: </p>
  
  <blockquote>
    <p>SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known</p>
  </blockquote>
  
  <p>Here is my docker-compose.yml file</p>
  
  <pre><code>version: '3.7'
  
  services:
    # Nginx
    web:
      image: nginx:latest
      ports:
        - '8080:80'
      volumes:
        - .:/app
        - .docker/nginx/site.conf:/etc/nginx/conf.d/default.conf
      links:
        - php
  
    # Database
    db:
      container_name: db
      image: mysql:5.7.24
      command: --default-authentication-plugin=mysql_native_password
      restart: always
      ports:
      - '3306:3306'
      environment:
        MYSQL_ROOT_PASSWORD: local_mysql_password
        MYSQL_DATABASE: partners
  
    # PHP
    php:
      build: .
      volumes:
        - .:/app
      links:
        - db
      depends_on:
        - db
  </code></pre>
  
  <p>And my Dockerfile for the php image</p>
  
  <pre><code>FROM php:7.2-fpm
  
  ADD . /app
  
  WORKDIR /app
  
  RUN apt-get update \
   &amp;&amp; apt-get install -y git libpng-dev libxml2-dev libzip-dev zip \
   &amp;&amp; docker-php-ext-configure zip --with-libzip \
   &amp;&amp; docker-php-ext-install \
      pdo_mysql \
      gd \
      zip \
   &amp;&amp; curl -sS https://getcomposer.org/installer \
    | php -- --install-dir=/usr/local/bin --filename=composer
  
  RUN composer install
  
  RUN php artisan migrate
  </code></pre>
  
  <p>I am using the following in my .env file for the DB connection</p>
  
  <pre><code>DB_CONNECTION=mysql
  DB_HOST=db
  DB_PORT=3306
  DB_DATABASE=partners
  DB_USERNAME=root
  DB_PASSWORD=local_mysql_password
  </code></pre>
  
  <p>I have tried tweaking the port, changing the service name, container_name, links/depends_on settings, and a handful of other things I can't recall at the moment. I have tried multiple solutions from here, reddit, and github but none have worked. Is there something basic I am overlooking?</p>