I have a laravel app that is running via a docker-compose file. Here's the file:
version: '3'
services:
#PHP and Apache
site:
user: 1000:1000
image: alfasoft/php:7.4.27
environment:
- PMA_HOST=db
- WEBWORK_SMTP_SERVER=mailhog
volumes:
- './:/var/www/html'
ports:
- 80:80
depends_on:
- mysql
- mailhog
#MySQL
mysql:
image: mysql:5.7.37
environment:
- MYSQL_DATABASE=pde
- MYSQL_ROOT_PASSWORD=[...]
- MYSQL_PASSWORD=<password>
volumes:
- '../../mysql:/var/lib/mysql'
ports:
- 3306:3306
#PHPMyAdmin
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8080:80
environment:
- PMA_ARBITRARY=1
#Mailhog
mailhog:
container_name: mailhog
user: 1000:1000
image: mailhog/mailhog
ports:
- 1025:1025 # smtp server
- 8025:8025 # web ui
And here's the mailing variables in my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Now, Mailhog is working fine, and whenever I try to send an email through the Laravel App, I receive it on Mailhog UI as expected.
But if I try to run a php artisan migrate:status
I get this error:
Swift_TransportException : Connection could not be established with host mailhog :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known
at /home/gustavo/Documents/alfasoft/projetos/perguntas-de-especialidade/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:261
257| }
258| $streamContext = stream_context_create($options);
259|
260| set_error_handler(function ($type, $msg) {
> 261| throw new Swift_TransportException('Connection could not be established with host '.$this->params['host'].' :'.$msg);
262| });
263| try {
264| $this->stream = stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
265| } finally {
Exception trace:
1 Swift_Transport_StreamBuffer::{closure}()
[internal]:0
2 stream_socket_client()
/home/gustavo/Documents/alfasoft/projetos/perguntas-de-especialidade/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:264
Please use the argument -v to see more details.
And this error also happen when I try to get anything from the Database from Tinker. Any ideas? Every other StackOverflow question I saw so far didn't help