Adminer for Sqlite in Docker

Recently i wanted to use Sqlite with Adminer in Docker and it turned out to be not so easy.
I actually thought i could just declare Adminer in a docker-compose.yml file with a volume mounted, similar as i would do for adminer with mysql.

Update: Today i would rather use the IntelliJ Database Tool for Sqlite administration.

But since Adminer is a popular hacking target they introduced a feature that does not allow to run adminer without a password, out of the box.
Sqlite database usually runs without password and dang, workaround needed!

So we need to add a plugin to adminer that allows password-less login and extend the official Adminer Docker image to include the plugin.

We add a script that loads the official password-less-login plugin and copy it to the plugins-enabled folder of the Adminer image

login-password-less.php:

<?php
require_once('plugins/login-password-less.php');

/** Set allowed password
 * @param string result of password_hash
 */
return new AdminerLoginPasswordLess(
    $password_hash = password_hash("admin", PASSWORD_DEFAULT)
);

Dockerfile:

FROM adminer
USER root
COPY login-password-less.php /var/www/html/plugins-enabled/login-password-less.php
#USER adminer # we run as root because of permissions problems on db file with the volume

In docker-compose.yml:

version: "3"
services:
  app:
    build: ./php
      - mailcatcher
    volumes:
      - "../:/app:rw"
      - "./php/cli/php.ini:/etc/php/7.3/cli/php.ini:ro"
      - "./php/fpm/php.ini:/etc/php/7.3/fpm/php.ini:ro"

  nginx:
    build: ./nginx
    depends_on:
      - app
    command: /bin/sh -c "nginx -g 'daemon off;'"
    volumes:
      - "..:/app:rw"
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    ports:
      - '8088:80'

  adminer:
    build: ./adminer
    restart: unless-stopped
    volumes:
      - "..:/app:rw"
    ports:
      - 8080:8080

File tree:

  • adminer
    – Dockerfile
    – login-password-less.php
  • nginx
  • php
  • docker-compose.yml

Note that since docker-compose.yml version 3 the volumes_from directive was removed in favor of top level volumes to share volumes across images. However this implementation is imho rather weird, so i jut duplicated the volumes declaration in the App container and Adminer container.
Feels rather wrong but thats all i could come up with. Any advice here is welcome.

Now that this is done we can open the Sqlite3 database with the pseudo-password “admin” and manage the database.

After all you could also just copy the one-file Adminer with plugin to the php container and run it from within the php container. Just adjust your Nginx config to allow calling the file directly and take care to not deploy Adminer to live.
There is also a project that bundles the plugin with Adminer to one file: https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/blob/master/build-adminer-4-sqlite3-into-one-file.sh