2

I'm using Docker with phpMyAdmin and everything works fine except that it timeout way too quickly if I don't use it for a moment. How can I change the limit before having to reconnect ?

Drakota
  • 337
  • 1
  • 4
  • 16
  • session timeout or request timeout? I'm pretty sure you solve this the same way as outside docker. – Grimmy Jul 27 '17 at 20:47
  • Session timeout, I've checked another answer and in phpMyAdmin there's suppose to be a setting to change to extend the timeout, but it's not there. – Drakota Jul 27 '17 at 20:49
  • Still relevant I guess? https://stackoverflow.com/questions/11272973/phpmyadmin-automatic-logout-time – Grimmy Jul 27 '17 at 20:51

2 Answers2

2

Is setting MAX_EXECUTION_TIME in your docker-compose (under 'environment') a possible solution?

Ken
  • 2,859
  • 4
  • 24
  • 26
1

After some research I have found an elegant solution. Refer to (https://hub.docker.com/r/phpmyadmin/phpmyadmin/) for information on config.user.inc.php.

The idea is you want to create a volume for this to store the following code.

config.user.inc.php

<?php
    $cfg['LoginCookieValidity'] = (86400 * 30); //86400 is 24 hours in seconds.  Therefore this is 30 days.
    ini_set('session.gc_maxlifetime', (86400 * 30));
?>

You can just put whatever time you want in seconds here, by default it was 24 minutes.

My docker compose file then looked like this for phpmyadmin

phpmyadmin:
    depends_on:
      - db_live
      - db_dev
    container_name: phpmyadmin
    image: phpmyadmin/phpmyadmin
    volumes:
     - ./phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
    hostname: localbeta.domain.com
    environment:
      PMA_ARBITRARY: 1
      UPLOAD_LIMIT: 25000000
    restart: always
    ports:
      - "8081:80"

The key here is the volumes command. It will create a local directory to change the config.user.inc.php to whatever you want now!

Another thing to note is that PhpMyAdmin will give you a hostname error if you run it and view the console output, to fix this just add the 'hostname' field to the docker compose. Then in your systems host file just add that to your list of hosts and point it to 127.0.0.1 for local testing and don't change anything for the actual beta and/or live servers (if you are using this for that)

You know you will do it right if you go to the settings and see the following for login cookie validity:

enter image description here

Joseph Astrahan
  • 8,659
  • 12
  • 83
  • 154
  • 1
    I found that I had to create the file first `/phpmyadmin/config.user.inc.php` otherwise it just created a directory with the name `config.user.inc.php` Works perfectly and solves a long running problem of getting phpmyadmin config working in docker. Thanks! – warmwhisky Sep 10 '22 at 13:26
  • Ah yes, I forgot to mention that! @warmwhisky, you do need to create the file first – Joseph Astrahan Sep 10 '22 at 18:19