How to add Magento 2 Docker phpmyadmin image in docker-compose.yml file?

You can add the PHPMyAdmin image snippet in the docker-compose YAML file that looks like below code snippet.

In Docker instance,

version: '3.0'
services:
  phpmyadmin:
    image: 'phpmyadmin/phpmyadmin:latest'
    environment:
      - PMA_HOST=<hostname>
      - PMA_USER=<db_user>
      - PMA_PASSWORD=<password>
    ports:
      - "8080:80"
    volumes:
      - /sessions
    networks:
      magento:
        aliases:
          - 'phpmyadmin.magento2.docker'

Using this code, you can directly access the phpmyadmin database from the browser.

For Warden,

php-fpm:
    ports:
            - "4000:4000"
            - "3001:3001"
    phpmyadmin:
        restart: always
        image: docker.io/library/phpmyadmin:latest
        hostname: ${WARDEN_ENV_NAME}-phpmyadmin
        domainname: phpmyadmin.${WARDEN_ENV_NAME}.test
        ports:
            - 8100:80
        environment:
            - PMA_HOSTS=${WARDEN_ENV_NAME}_db_1
            - PMA_USER=magento
            - PMA_PASSWORD=magento
            - PMA_ABSOLUTE_URI=http://phpmyadmin.${TRAEFIK_DOMAIN}