This article is the continuation of my previous https://dev.to/ibrarturi/setup-docker-container-for-mailhog-to-use-it-with-laravel-app-4g00 in which we setup docker container for https://github.com/mailhog/MailHog to use it with your Laravel app. In this article, I am going to explain how to add new container for MySQL 8.0 that can be used with your Laravel app. # MySQL Service db: platform: linux/x86_64 image: mysql:8.0.28 container_name: mysql-8 environment: #MYSQL_USER: 'foo' ports: - 3307:3306 volumes: - docker_workspace_mysql:/var/lib/mysql networks: - docker_workspace_network volumes: docker_workspace_mysql: external: false networks: docker_workspace_network: driver: bridge To setup your Laravel app to use this MySQL container, open your.env file and change the DB credentials to the following: DB_DATABASE=db-name-here DB_USERNAME=root DB_PASSWORD=secret DB_PORT=3307 Now, open your Laravel app and now it should be connected to MySQL from docker container
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners