Skip to content

Default login - tutorial #231

Description

@LajosCseppento

I figured how to auto-login, if you want you could add this to the Docker Hub docs. Basically it just automates the login form (this worked out the best).

compose.yaml:

services:
  postgres:
    image: postgres:18
    # ...

  adminer:
    image: adminer:5
    ports:
      # ...
    volumes:
      - ./adminer-custom.php:/var/www/html/index.php:ro
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test:
        [
          "CMD",
          "php",
          "-r",
          "exit(file_get_contents('http://localhost:8080/') ? 0 : 1);",
        ]
      start_period: 10s
      interval: 30s
      timeout: 10s
      retries: 3

adminer-custom.php:

<?php
// See https://www.adminer.org/en/extension/
// What worked best is to just simply override the login form.

function adminer_object() {

    class MyDbLocalAdminer extends Adminer\Adminer {

        function loginForm() {
            echo Adminer\input_hidden('auth[driver]', 'pgsql');
            echo Adminer\input_hidden('auth[server]', 'postgres');
            echo Adminer\input_hidden('auth[username]', 'mydb-local');
            echo Adminer\input_hidden('auth[password]', 'mydb-local');
            echo Adminer\input_hidden('auth[db]', 'mydb-local');
            echo Adminer\script("document.querySelector('form').submit();");
        }
    }

    return new MyDbLocalAdminer;
}

include '/var/www/html/adminer.php';

Kudos to Claude for vibing (don't worry, I cleaned it up).

Tested on latest Firefox, Brave, Chrome, Edge.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions