Docker Compose, Add MySQL support to PHP-FPM 7. Call to undefined function mysql_connect()
<p>I'm using Docker Compose to build my first Docker machine. I want setup Docker to have PHP-FPM 7, Nginx and MySQL (Using MariaDB).</p>

<p>Here is my docker-compose.yml</p>

<pre><code>version: '2'
services:
nginx:
image: nginx:latest
ports:
  - "80:80"
volumes:
  - ./nginx/site.conf:/etc/nginx/conf.d/default.conf
  - ./logs/nginx-error.log:/var/log/nginx/error.log
  - ./logs/nginx-access.log:/var/log/nginx/access.log
  - ./public:/usr/share/nginx/html
links:
  - phpfpm

phpfpm:
image: php:7-fpm
volumes:
  - ./public:/usr/share/nginx/html
  - ./logs/log.conf:/usr/local/etc/php-fpm.d/zz-log.conf

mariadb:
image: mariadb
environment:
  MYSQL_ROOT_PASSWORD: admin
  MYSQL_DATABASE: admin
  MYSQL_USER: admin
  MYSQL_PASSWORD: admin
volumes:
 - ./database:/var/lib/mysql
</code></pre>

<p>Docker starts up correctly but when I try using mysql_connect to connect to the database in index.php I get the error:</p>

<blockquote>
  <p>Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /usr/share/nginx/html/index.php:7 Stack trace: #0 {main} thrown in /usr/share/nginx/html/index.php on line 7</p>
</blockquote>

<p>Here is my index.php</p>

<pre><code>&lt;?php
 $username = "admin";
 $password = "admin";
 $hostname = "localhost";

 //connection to the database
 $dbhandle = mysql_connect($hostname, $username, $password)
   or die("Unable to connect to MySQL");
 echo "Connected to MySQL&lt;br&gt;";
 ?&gt;
</code></pre>

<p>How can I set up PHP-FPM to use MySQL?</p>

<p>Thanks a lot</p>