PHPMyAdmin docker-compose setup to access MySQL database running on docker host

Version for use with nginx, Apache etc

This version has a port mapped out to the more or less random port 17035

services:
  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: phpmyadmin
    environment:
      PMA_SOCKET: /run/mysqld/mysqld.sock
    volumes:
      - /run/mysqld/mysqld.sock:/run/mysqld/mysqld.sock
    ports:
      - 17035:80
    extra_hosts:
      - "host.docker.internal:host-gateway"

nginx config

server {
    server_name phpmyadmin.my-domain.com;

    access_log /var/log/nginx/phpmyadmin.access_log;
    error_log /var/log/nginx/phpmyadmin.error_log info;

    root /var/sites/phpmyadmin.my-domain.com;

    location / {
        proxy_pass http://127.0.0.1:17035;
        proxy_http_version 1.1;
        proxy_read_timeout 3600s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        add_header X-Frontend-Host $host;
    }

    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
}

server {
    if ($host = phpmyadmin.my-domain.com) {
        return 301 https://$host$request_uri;
    }

    server_name phpmyadmin.my-domain.com;

    listen 80;
    return 404;
}