Auto setting multiple mysql for docker phpmyadmin
1.9K
This project is mainly inspired by treafik, treafik uses lables to achieve automatic setting loading blance, I think I can also let phpmyadmin achieve automatic increase of db The setting, so I only need a set of phpmyadmin in my development environment to access the mysql of each project.
This project is based on the official phpmyadmin. In addition to the additional settings of this project, the other settings are the same as the official ones.
The example path in the source code has two files that can be used as test example, as explained below:
Filename : docker-compose.yml
version: '3.5'
services:
phpmyadmin:
image: 'pigochu/phpmyadmin-autoconfig'
environment:
- PHPMYADMIN_AUTOCONFIG_INSTANCE=phpmyadmin
ports:
- "9080:80"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- default
- example
# Please execute the following command
# docker network create --attachable -d bridge example_net
networks:
example:
external:
name: example_net
This file only defines a service phpmyadmin, which has a few points to note.
Filename : docker-compose.db.yml
version: '3.5'
services:
db1:
image: mariadb
labels:
- phpmyadmin.autoconfig.target=phpmyadmin
- phpmyadmin.autoconfig.cfg.verbose=database-1
- phpmyadmin.autoconfig.cfg.AllowNoPassword=true
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
networks:
- default
- example
db2:
image: mariadb
labels:
- phpmyadmin.autoconfig.target=phpmyadmin
- phpmyadmin.autoconfig.cfg.verbose=database-2
- phpmyadmin.autoconfig.cfg.AllowNoPassword=true
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
networks:
- default
- example
# Please execute the following command
# docker network create --attachable -d bridge example_net
networks:
example:
external:
name: example_net
This example defines two services, db1 and db2, using the official mariadb image, and the networks section uses example_net to allow phpmyadmin and mariadb to communicate with each other.
Lables must be defined in db1 and db2, as follows:
Execute the following command
docker network create --attachable -d bridge example_net
docker-compose up -d
docker-compose -f docker-composer.db.yml up -d
This service phpmyadmin uses port 9080 , so after opening http://localhost:9080, you can use the account root to login without entering a password.
Attention!! Sometimes you may get the error message "Connection refused". According to my test, when started the official MariaDb, it seems that it will be initialized first, and it takes a few minutes to connect correctly. Once it can be connected after few minutes, and next time restart container should also be connected successful.
Pigo Chu [email protected]
Content type
Image
Digest
Size
163.4 MB
Last updated
about 5 years ago
docker pull pigochu/phpmyadmin-autoconfig