Skip to content

Instantly share code, notes, and snippets.

@diogoko
Last active December 23, 2021 15:27
Show Gist options
  • Save diogoko/621ceba223a1404de0c6bd12d1ed4f04 to your computer and use it in GitHub Desktop.
Save diogoko/621ceba223a1404de0c6bd12d1ed4f04 to your computer and use it in GitHub Desktop.
Laravel Sail with phpMyAdmin
version: "3"
services:
phpmyadmin:
image: "phpmyadmin:5"
ports:
- "${FORWARD_PHPMYADMIN_PORT:-8888}:80"
environment:
PMA_HOST: "mysql"
PMA_USER: "${DB_USERNAME}"
PMA_PASSWORD: "${DB_PASSWORD}"
PMA_ABSOLUTE_URI: "http://localhost:${FORWARD_PHPMYADMIN_PORT:-8888}/"
volumes:
- "sailphpmyadmin:/sessions"
networks:
- sail
volumes:
sailphpmyadmin:
driver: local

Quick start

Download docker-compose.override.yml shown below to your project's directory.

Slower start

If you prefer you can edit the existing docker-compose.yml.

Add a new service:

services:
    ...
    phpmyadmin:
        image: 'phpmyadmin:5'
        ports:
            - '${FORWARD_PHPMYADMIN_PORT:-8888}:80'
        environment:
            PMA_HOST: 'mysql'
            PMA_USER: '${DB_USERNAME}'
            PMA_PASSWORD: '${DB_PASSWORD}'
            PMA_ABSOLUTE_URI: 'http://localhost:${FORWARD_PHPMYADMIN_PORT:-8888}/'
        volumes:
            - 'sailphpmyadmin:/sessions'
        networks:
            - sail

Add a new volume to store the session state:

volumes:
    ...
    sailphpmyadmin:
        driver: local

Usage

After running sail up, phpMyAdmin will be available at http://localhost:8888/. The port may be changed by setting the FORWARD_PHPMYADMIN_PORT environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment