Prerequisites #
Folder Structure #
# Create folder structure
sudo mkdir -p /opt/phpmyadmin && cd /opt/phpmyadmin
With Predefined Server (HTTP) #
Docker Network #
# Create external Docker network
sudo docker network create phpmyadmin
SQL Server Example #
# Create folder structure
sudo mkdir -p /opt/mysql && cd /opt/mysql
# Create Docker Compose file
sudo vi docker-compose.yml
version: '3.9'
services:
db-service:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: sql-root-pw
volumes:
- ./db_data:/var/lib/mysql
networks:
- default
- phpmyadmin
restart: unless-stopped
networks:
phpmyadmin:
external: true
# Create / start Docker stack
sudo docker compose up -d
phpmyadmin #
Environment File #
# Create environment file
sudo vi .env
PMA_HOST=db-service
PMA_PORT=3306
PMA_USER=root
PMA_PASSWORD=sql-root-pw
Note: Remove the PMA_USER
variables PMA_PASSWORD
to define the DB user & pw via the webinterface.
Docker Compose #
# Create Docker Compose file
sudo vi docker-compose.yml
version: '3.9'
services:
phpmyadmin:
image: phpmyadmin:latest
ports:
- 8080:80
env_file:
- .env
networks:
- phpmyadmin
restart: unless-stopped
networks:
phpmyadmin:
external: true
# Create / start Docker stack
sudo docker compose up -d
Webinterface #
# Open webinterface
IP:8080
With Predefined Server (HTTPS) #
Docker Network #
# Create external Docker network
sudo docker network create phpmyadmin
sudo docker network create nginx
SQL Server Example #
# Create folder structure
sudo mkdir -p /opt/mysql && cd /opt/mysql
# Create Docker Compose file
sudo vi docker-compose.yml
version: '3.9'
services:
db-service:
image: mariadb:latest
environment:
MYSQL_ROOT_PASSWORD: sql-root-pw
volumes:
- ./db_data:/var/lib/mysql
networks:
- default
- phpmyadmin
restart: unless-stopped
networks:
phpmyadmin:
external: true
# Create / start Docker stack
sudo docker compose up -d
phpmyadmin #
Environment File #
# Create environment file
sudo vi .env
PMA_ABSOLUTE_URI="https://phpmyadmin.jklug.work"
PMA_HOST=db-service
PMA_PORT=3306
PMA_USER=root
PMA_PASSWORD=sql-root-pw
Note: Remove the PMA_USER
variables PMA_PASSWORD
to define the DB user & pw via the webinterface.
Docker Compose #
# Create Docker Compose file
sudo vi docker-compose.yml
version: '3.9'
services:
phpmyadmin:
image: phpmyadmin:latest
ports:
- 8080:80
env_file:
- .env
networks:
- phpmyadmin
- nginx
restart: unless-stopped
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
- /etc/letsencrypt:/etc/letsencrypt
networks:
- nginx
restart: unless-stopped
networks:
phpmyadmin:
external: true
nginx:
external: true
Nginx Default Configuration #
# Create Nginx default configuration file
sudo vi default.conf
# default.conf
server {
listen 80;
server_name phpmyadmin.jklug.work;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name phpmyadmin.jklug.work;
ssl_certificate /etc/letsencrypt/live/phpmyadmin.jklug.work/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/phpmyadmin.jklug.work/privkey.pem;
location / {
proxy_pass http://phpmyadmin:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# Create / start Docker stack
sudo docker compose up -d
Webinterface #
# Open the webinterface
phpmyadmin.jklug.wor
With Arbitrary Server (HTTP) #
Docker Compose #
# Create Docker Compose file
sudo vi docker-compose.yml
version: '3.9'
services:
phpmyadmin:
image: phpmyadmin:latest
ports:
- 8080:80
environment:
- PMA_ARBITRARY=1
networks:
- default
restart: unless-stopped
# Create / start Docker stack
sudo docker compose up -d
Webinterface #
# Open webinterface
IP:8080
With Arbitrary Server (HTTPS) #
Docker Network #
# Create external Docker network
sudo docker network create nginx
Docker Compose #
# Create Docker Compose file
sudo vi docker-compose.yml
version: '3.9'
services:
phpmyadmin:
image: phpmyadmin:latest
ports:
- "8080:80"
environment:
- PMA_ARBITRARY=1
networks:
- default
- nginx
restart: unless-stopped
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
- /etc/letsencrypt:/etc/letsencrypt
networks:
- nginx
restart: unless-stopped
networks:
nginx:
external: true
Nginx Default Configuration #
# Create Nginx default configuration file
sudo vi default.conf
# default.conf
server {
listen 80;
server_name phpmyadmin.jklug.work;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name phpmyadmin.jklug.work;
ssl_certificate /etc/letsencrypt/live/phpmyadmin.jklug.work/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/phpmyadmin.jklug.work/privkey.pem;
location / {
proxy_pass http://phpmyadmin:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# Create / start Docker stack
sudo docker compose up -d
Webinterface #
# Open the webinterface
phpmyadmin.jklug.work
- Connect to MySQL / MariaDB server
Links #
# DockerHub
https://hub.docker.com/_/phpmyadmin