Laravel Docker Unable to insert data

I was learning docker and was able to run docker-compose on production. Below is my production file

version: "3"

services:
  app:
    container_name: myapp
    build:
      context: .
      dockerfile: docker/Fpm.Production.Dockerfile
    working_dir: /var/www/html/dockerapps/laravel-docker-boilerplate
    volumes:
      - .:/var/www/html/dockerapps/laravel-docker-boilerplate
    links:
      - db
    networks:
      - mynet
  db:
    image: mysql:5.7
    container_name: db
    volumes:
      - dbdata:/var/lib/mysql
    environment:
      MYSQL_DATABASE: laraapp
      MYSQL_USER: laraveluser
      MYSQL_PASSWORD: laravel
      MYSQL_ROOT_PASSWORD: 123456
    networks:
      - mynet
#Volumes
volumes:
  dbdata:
    driver: local
#Docker Networks
networks:
  mynet:
    driver: bridge

DB config in .env

DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=laraapp
DB_USERNAME=laraveluser
DB_PASSWORD=laravel

Migration is running successfully but when I try to create new user I am facing this below error:

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No address associated with hostname (SQL: select count(*) as aggregate from `users` where `email` = [email protected])

Thanks in advance 🙂

Source: StackOverflow