Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hanisharun's avatar

Laravel multiple database Docker deploymeny

I need help with my laravel deployment using docker on the live server. In the beginning, the system was developed with single mysql database. It was deployed on the server using docker and has worked perfectly. Since I need to pull data from another db (using sqlsrv and mysql) on a different server, I added a connection in the env file and config/database.php.

In the details, the system is using one mysql db (A) which is the default db when installing laravel, two mysql db (B) on two different server, and five sqlsrv db (C) on five different servers.

Everything works fine in localhost. I was able to pull data from all servers. Then I try to deploy it on the live server using the same docker-compose, but I added sqlsrv and pdo_sqlsrv extension on the Dockerfile. The build process went good as per checked on phpinfo(), all required pdo are there.

I able to login to the system and pull data from A and C, but not C. When login using C, it just displayed the message site can't be reached. I wonder which part I'm missing. Current docker compose have 3 container which are the app, webserver and db (default mysql db) . Do I need to add another container for sqlsrv? If so, how do I configure my env and etc?

I'm using Laravel 8, PHP7.4

Thanks in advance.

0 likes
0 replies

Please or to participate in this conversation.