Hello everyone,
I’m a bit stumped on this one and I hope to get help from you guys.
I have a working docker-compose file on my home box (Linux Mint 18 Sarah): apache, php, phpmyadmin and mysql work fine together. My Symfony based project works fine.
The same docker-compose.yml file on my work box (Ubuntu 18.04) yields the dreaded php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
.
Php container does not seem to be able to resolve mysql
(service name) in the DB connection:
DATABASE_URL=mysql://sf4:sf4@mysql:3306/backoffice
I get a different error message if I change it to localhost
DATABASE_URL=mysql://sf4:sf4@localhost:3306/backoffice
An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory
I am using the same network on both computers.
Docker-compose.yml is as follows:
version: '3'
services:
apache:
build: .docker/apache
container_name: sf4_apache
ports:
- 80:80
expose:
- 80
- 9000 # x-debug
volumes:
- .docker/config/vhosts:/etc/apache2/sites-enabled
- .:/var/www/back-office
depends_on:
- php
mysql:
image: mysql:5.7.23
container_name: sf4_mysql
volumes:
- .docker/data/db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: backoffice
MYSQL_USER: sf4
MYSQL_PASSWORD: sf4
php:
build: .docker/php
container_name: sf4_php
volumes:
- .:/var/www/back-office
environment:
- maildev_host=sf4_maildev
depends_on:
- maildev
- mysql
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: sf4_phpmyadmin
depends_on:
- mysql
ports:
- 8080:80
links:
- mysql
environment:
PMA_HOSTS: mysql
maildev:
image: djfarrelly/maildev
container_name: sf4_maildev
ports:
- 8001:80
Thanks!