postfixadmin / docker

Docker Image for PostfixAdmin
https://hub.docker.com/_/postfixadmin
GNU General Public License v2.0
72 stars 21 forks source link

No longer able to specify custom database_port(POSTFIXADMIN_DB_PORT: 3307) #35

Closed CryDeTaan closed 3 years ago

CryDeTaan commented 3 years ago

Hi

In the latest version it is not longer possible to pass the DB port as a environment variable:

This is my docker-compose.yml, its essentially the same example as in the README I only added the MYSQL_TCP_PORT for the mysql container and then also the POSTFIXADMIN_DB_PORT for the postfixadmin container.

version: '3'

services:
   db:
     image: mysql:5.7
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: notSecureChangeMe
       MYSQL_DATABASE: postfixadmin
       MYSQL_USER: postfixadmin
       MYSQL_PASSWORD: postfixadminPassword
       MYSQL_TCP_PORT: 3307

   postfixadmin:
     depends_on:
       - db
     image: postfixadmin
     ports:
       - "8000:80"
     restart: always
     environment:
       POSTFIXADMIN_DB_TYPE: mysqli
       POSTFIXADMIN_DB_HOST: db
       POSTFIXADMIN_DB_PORT: 3307
       POSTFIXADMIN_DB_USER: postfixadmin
       POSTFIXADMIN_DB_NAME: postfixadmin
       POSTFIXADMIN_DB_PASSWORD: postfixadminPassword
       POSTFIXADMIN_SMTP_SERVER: postfix
       POSTFIXADMIN_SMTP_PORT: 25

This is the output and you'll see the error after the Write config to /var/www/html/config.local.php section.

db_1            | 2021-01-17T13:10:15.888201Z 0 [Note] Event Scheduler: Loaded 0 events
db_1            | 2021-01-17T13:10:15.888506Z 0 [Note] mysqld: ready for connections.
db_1            | Version: '5.7.32'  socket: '/var/run/mysqld/mysqld.sock'  port: 3307  MySQL Community Server (GPL)
postfixadmin_1  | Complete! Postfixadmin has been successfully copied to /var/www/html
db_1            | 2021-01-17T13:10:15.935272Z 2 [Note] Got an error reading communication packets
postfixadmin_1  | Write config to /var/www/html/config.local.php
postfixadmin_1  | <?php
postfixadmin_1  |       $CONF['database_type'] = 'mysqli';
postfixadmin_1  |       $CONF['database_host'] = 'db';
postfixadmin_1  |       $CONF['database_port'] = '3307';
postfixadmin_1  |       $CONF['database_user'] = 'postfixadmin';
postfixadmin_1  |       $CONF['database_password'] = 'postfixadminPassword';
postfixadmin_1  |       $CONF['database_name'] = 'postfixadmin';
postfixadmin_1  |       $CONF['setup_password'] = 'changeme';
postfixadmin_1  |       $CONF['smtp_server'] = 'postfix';
postfixadmin_1  |       $CONF['smtp_port'] = '25';
postfixadmin_1  |       $CONF['configured'] = true;
postfixadmin_1  |       ?>
postfixadmin_1  |  ** Running database / environment upgrade.php
postfixadmin_1  | Exception running PostfixAdmin query: CREATE TABLE IF NOT EXISTS `config` (
postfixadmin_1  |         `id` int(11) not null auto_increment primary key,
postfixadmin_1  |         `name`  VARCHAR(20) /*!40100 CHARACTER SET latin1 COLLATE latin1_general_ci */ NOT NULL DEFAULT '',
postfixadmin_1  |         `value` VARCHAR(20) /*!40100 CHARACTER SET latin1 COLLATE latin1_general_ci */ NOT NULL DEFAULT '',
postfixadmin_1  |         UNIQUE name ( `name` )
postfixadmin_1  |         )
postfixadmin_1  |       COMMENT = 'PostfixAdmin settings' PDOException: SQLSTATE[HY000] [2002] Connection refused in /var/www/html/functions.inc.php:1648
postfixadmin_1  | Stack trace:
postfixadmin_1  | #0 /var/www/html/functions.inc.php(1648): PDO->__construct('mysql:host=db;d...', 'postfixadmin', 'postfixadminPas...', Array)
postfixadmin_1  | #1 /var/www/html/functions.inc.php(1787): db_connect()
postfixadmin_1  | #2 /var/www/html/public/upgrade.php(328): db_execute('CREATE TABLE IF...', Array, true)
postfixadmin_1  | #3 /var/www/html/public/upgrade.php(149): db_query_parsed('\n        CREATE...', 0, ' COMMENT = 'Pos...')
postfixadmin_1  | #4 {main}
postfixadmin_1  |
postfixadmin_1  | Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] Connection refused in /var/www/html/functions.inc.php:1648
postfixadmin_1  | Stack trace:
postfixadmin_1  | #0 /var/www/html/functions.inc.php(1648): PDO->__construct('mysql:host=db;d...', 'postfixadmin', 'postfixadminPas...', Array)
postfixadmin_1  | #1 /var/www/html/functions.inc.php(1812): db_connect()
postfixadmin_1  | #2 /var/www/html/functions.inc.php(1775): db_query('SELECT value FR...', Array)
postfixadmin_1  | #3 /var/www/html/functions.inc.php(2107): db_query_one('SELECT value FR...')
postfixadmin_1  | #4 /var/www/html/public/upgrade.php(152): check_db_version(false)
postfixadmin_1  | #5 {main}
postfixadmin_1  |   thrown in /var/www/html/functions.inc.php on line 1648
db_1            | 2021-01-17T13:10:16.454841Z 3 [Note] Got an error reading communication packets

Regards ^C

DavidGoodwin commented 3 years ago

will it work if you defined the host as 'db;port=3307' ?

CryDeTaan commented 3 years ago

Yep thanks @DavidGoodwin that did the trick,

For anyone else reading this, remember to include the ' in solution above, i.e. 'db;port=3307'