Hello,
I wish to setup a simple LAMP docker using:
php apache
mariadb
phpmyadmin
But I can’t get it to work. Could anyone give a yml or Dockerfile example to make it work? I’m on fedora 29 using the F28 docker repository.
Details:
yml file:
version: '3'
services:
php-apache:
build:
context: ./php-apache
ports:
- 80:80
volumes:
- ./html:/var/www/html
links:
- 'mariadb'
mariadb:
image: mariadb:10
volumes:
- ./db:/var/lib/mysql
environment:
TZ: "Europe/Amsterdam"
MYSQL_ALLOW_EMPTY_PASSWORD: "no"
MYSQL_ROOT_PASSWORD: "Adminpass-123"
MYSQL_USER: 'user1'
MYSQL_PASSWORD: 'Userpass-123'
MYSQL_DATABASE: 'db1'
phpmyadmin:
image: corbinu/docker-phpmyadmin
links:
- 'mariadb'
ports:
- 8181:80
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: Adminpass-123
MYSQL_PORT_3306_TCP_ADDR: mariadb
Dockerfile in php-apache:
FROM php:7-apache
RUN docker-php-ext-install pdo pdo_mysql mysqli
Phpmyadmin login at http://127.0.0.1:8181 works, but corbinu/docker-phpmyadmin is depreciated. If I replace “image: corbinu/docker-phpmyadmin” with “image: phpmyadmin/phpmyadmin” in the yml file, and login to phpmyadmin I get:
mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name does not resolve
mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name does not resolve
I can login to phpmyadmin with corbinu/docker-phpmyadmin, but get errors:
Connection for controluser as defined in your configuration failed.
www/html/test.php
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
// include('config.php');
$dbhost = "localhost";
$dbuser = "user2";
$dbpass = "Userpass-123";
$db = "db1";
$db = mysqli_connect($dbhost,$dbuser,$dbpass,$db)
or die('Error connecting to MySQL server!');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>php test</title>
</head>
<body>
test
</body>
</html>
Gives:
**Warning** : mysqli_connect(): (HY000/2002): No such file or directory in **/var/www/html/test1.php** on line **13**
Error connecting to MySQL server!
All I need is a working yml or Dockerfile for a LAMP setup with phpmyadmin. Can’t seem to find anything on the web explaining how to make a dockerfile or yml file with this combination.
Thank you