version: '3' services: db: image: mysql:5.7 restart: always environment: MYSQL_DATABASE: "$MYSQL_DB_DNAME" # So you don't have to use root, but you can if you like MYSQL_USER: "$MYSQL_DB_USERNAME" # You can use whatever password you like MYSQL_PASSWORD: "$MYSQL_DB_PASSWORD" # Password for root access MYSQL_ROOT_PASSWORD: "$MYSQL_DB_PASSWORD" ports: # : < MySQL Port running inside container> #Host port is used for outside communication #MYSQL internal port used for Networked service-to-service communication - '3000:3306' volumes: - my-db:/var/lib/mysql web-app: depends_on: - db restart: on-failure links: - "db:db" environment: MYSQL_DB_HOST: ${MYSQL_DB_HOST} MYSQL_DB_PORT: ${MYSQL_DB_PORT} MYSQL_DB_USERNAME: ${MYSQL_DB_USERNAME} MYSQL_DB_PASSWORD: ${MYSQL_DB_PASSWORD} MYSQL_DB_DNAME: ${MYSQL_DB_DNAME} build: context: . dockerfile: Dockerfile ports: - "8080:8080" ## Names our volume volumes: my-db: