Automatic piwik installation for a custom docker Image could not create a directory

I am creating a custom docker image using piwik. What I want to acheive is by running thin container to have automatically the database configured and piwik fully installed with the only thing remaining is to create a default user. Also I wanted to have utility scripts for backup and restore.

Therefore I created this:

And I managed using php console config:set to configure the database connection. So using the foillowing entrypoint script:


if [ ! -e piwik.php ]; then
  cp -R /usr/src/piwik/* /var/www/html

  mkdir "/var/www/html/tmp/cache/tracker/"
  chmod 777 -R /var/www/html/tmp/cache
  find /var/www/html -iname "*.php" | xargs chmod +x

  chown -R www-data:www-data .

echo "Mariadb Addr:"$DB_PORT_3306_TCP_ADDR
  echo "Waiting for mysql to start at ${PIWIK_DB_HOST} using port ${PIWIK_DB_PORT}..."
  while ! mysqladmin ping -h"$PIWIK_DB_HOST" -P $PIWIK_DB_PORT --silent; do
    if [ $COUNTER -gt 10 ] ; then
      exit 1
      echo "Connecting to ${PIWIK_DB_HOST} Failed"
      sleep 1

  echo "Setting up the database connection info"

  if [ "$PIWIK_DB_USER" = 'root' ]; then

if ! mysql -h"$PIWIK_DB_HOST" -P $PIWIK_DB_PORT -u ${PIWIK_DB_USER} -p${PIWIK_DB_PASSWORD}  -e ";" ; then
  echo "The user does not exist to the mysql server: ${PIWIK_DB_HOST}"
  exit 1

php console config:set --section="database" --key="host" --value=${PIWIK_DB_HOST}
php console config:set --section="database" --key="port" --value=${PIWIK_DB_PORT}
php console config:set --section="database" --key="username" --value=${PIWIK_DB_USER}
php console config:set --section="database" --key="password" --value=${PIWIK_DB_PASSWORD}
php console config:set --section="database" --key="tables_prefix" --value="piwik_"

php index.php

exec "$@"

I try to perform an cli installation of piwik. But when I visit the piwik page from my browser I get the follwing error:

The directory “/var/www/html/tmp/cache/tracker/” does not exist and could not be created.

Do you have any sort of idea how I will fix this problem?