Muhammad Yasir Amin

Loading websiteโ€ฆ

More from Muhammad Yasir Amin

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Subscribe on YouTube

Laravel Docker: Install Adminer with a MySQL or PostgreSQL Database

๐Ÿ› ๏ธ Laravel Tutorials4 min read

Laravel Docker: Install Adminer with a MySQL or PostgreSQL Database

Muhammad Yasir Amin

Muhammad Yasir Amin

Senior Full Stack Engineerโ€ขNov 6, 2026
Laravel Docker: Install Adminer with a MySQL or PostgreSQL Database

To run Adminer with Laravel in Docker, add an adminer service to your docker-compose.yml, set ADMINER_DEFAULT_SERVER to your database service name, publish a port such as 8081, and open it in the browser. Log in with the same credentials Laravel uses. Adminer is a single-file database manager that works with MySQL, PostgreSQL, SQLite and more, so it suits projects that are not locked to one engine.

This guide uses Laravel 13 (PHP 8.3 or newer) with a MySQL container, then shows how to switch the same Adminer service to PostgreSQL.

Why use Adminer instead of a desktop client?

  • It runs next to your app, so the whole team gets the same tool by running docker compose up.
  • There is nothing to install on the host.
  • It can talk to any database service on the Compose network by name.

What do I need before I start?

  • Docker with the Compose plugin.
  • A Laravel project containerised with a database service. The example calls it db.
  • Matching credentials in the compose file and in Laravel's .env.

Step 1: How do I add the Adminer service?

YAML
services:
  db:
    image: mysql:8.4
    environment:
      MYSQL_DATABASE: laravel
      MYSQL_USER: laravel
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: root-secret
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - app

  adminer:
    image: adminer:latest
    restart: unless-stopped
    depends_on:
      - db
    environment:
      ADMINER_DEFAULT_SERVER: db
    ports:
      - "8081:8080"
    networks:
      - app

volumes:
  db_data:

networks:
  app:

Adminer listens on port 8080 inside the container. The mapping 8081:8080 exposes it as 8081 on your machine so it does not clash with a web server you may already run on 8080. I did not start these containers for this article; check current image tags on Docker Hub and pin one.

Step 2: How do I start and open it?

Code
docker compose up -d adminer
docker compose logs adminer

Open http://localhost:8081. Choose MySQL as the system. The server field is already filled with db. Enter the user laravel, password secret and database laravel.

Step 3: How do I connect Laravel to the same database?

Code
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secret
Code
docker compose exec app php artisan migrate --seed

Reload Adminer and open the laravel database. Your tables should be listed. Replace app with your PHP service name.

How do I use Adminer with PostgreSQL?

Replace the database service and the Laravel variables. Adminer does not need a different image:

YAML
db:
    image: postgres:17
    environment:
      POSTGRES_DB: laravel
      POSTGRES_USER: laravel
      POSTGRES_PASSWORD: secret
    volumes:
      - pg_data:/var/lib/postgresql/data
    networks:
      - app
Code
DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=secret

In Adminer choose PostgreSQL as the system. Add pg_data: to the top-level volumes list.

What can I do with Adminer day to day?

  • Inspect the result of a migration or a seeder.
  • Look at rows in the jobs and failed_jobs tables when debugging queues.
  • Run a one-off SQL query and export the result.
  • Compare the table structure with what your migration should have created.

How do I keep Adminer safe?

  • Run it in development only. Do not expose it on a public server.
  • If you need it remotely, bind to localhost, for example "127.0.0.1:8081:8080", and use an SSH tunnel.
  • Use the application database user, not root.
  • Stop the service when you are done: docker compose stop adminer.

What are the common mistakes?

  • Entering localhost as the server. Inside the Adminer container this means Adminer itself. Use the service name, here db.
  • Wrong system selected. Choosing MySQL for a PostgreSQL server gives a connection error.
  • Port conflict. Change the left side of the port mapping.
  • Stale volume. Database credentials only apply when the volume is first created. Changing them later has no effect until you reset the volume, which deletes data.
  • Different networks. The services must share a network for the name to resolve.

How do I verify the setup?

  1. docker compose ps lists adminer and db as running.
  2. The login page opens on port 8081 and accepts your credentials.
  3. After php artisan migrate, the migrations table is visible.

FAQ

What is the difference between Adminer and phpMyAdmin?

Adminer is a single PHP file that supports several database engines. phpMyAdmin focuses on MySQL and MariaDB and has more features for them.

Can Adminer connect to a database outside Docker?

Yes. Enter the host name or IP in the server field. From a container, reaching a database on your host usually needs host.docker.internal on Docker Desktop.

Is it safe to leave Adminer running?

Not on a server reachable from the internet. Treat it like a root-level door to your data.

References

Article Index & Topic Tags
DockerLaravelDatabaseAdminer

YouTube Channel

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Muhammad Yasir Amin
Available for Contracts
Author & Solutions Architect

Senior Full Stack Engineer

Independent Senior Full Stack Engineer working on Laravel, React and Next.js applications, APIs and delivery workflows.

Laravel & PHP ApplicationsReact & Next.js InterfacesREST APIs & IntegrationsDatabase Queries & DebuggingDocker Development WorkflowsClear Scope & Handover
Discuss Your Next Step

What Does Your Application Need Next?

Share your current system, the problem you want to solve and what a useful result looks like. We can identify the right starting point and agree on a practical scope.

Technical Audit

Find the Next Useful Fix

Application Development

Scoped, Reviewable Milestones

Ongoing Support

Agreed Capacity and Priorities

Share your goals, current stack and requirements before the call.