I am trying to containerize my Laravel project. I have the following services in my docker-compose.yml
- laravel_app
- database
- nginx
- phpmyadmin
All of them are running okay except PHPMyAdmin. It gets built and does serve the phpMyAdmin login page but I get the following errors when I enter the credentials.
Cannot log in to the MySQL server
mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname
mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname
Here is my docker-compose.yml snippet that includes my database service and phpmyadmin service
#The Database
database:
container_name: mysql_database
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=dev-db"
- "MYSQL_USER=phpmyadmin"
- "MYSQL_PASSWORD=phpmyadmin"
- "MYSQL_ROOT_PASSWORD=123456"
ports:
- 8991:3306
#PHPMyAdmin Service
phpmyadmin:
container_name: phpmyadmin
image: phpmyadmin/phpmyadmin
ports:
- "8992:80"
depends_on:
- database
environment:
- "PMA_HOST:database"
- "MYSQL_USER:phpmyadmin"
- "MYSQL_PASSWORD:phpmyadmin"
- "MYSQL_ROOT_PASSWORD:123456"
- "UPLOAD_LIMIT:3000000000"
# redis
cache:
image: redis:3.0-alpine
volumes:
dbdata:
