Skip to content

Instantly share code, notes, and snippets.

@hasinhayder
Last active July 2, 2022 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasinhayder/b1467216c353f5032575b79b53ef0394 to your computer and use it in GitHub Desktop.
Save hasinhayder/b1467216c353f5032575b79b53ef0394 to your computer and use it in GitHub Desktop.
mariadb and phpmyadmin docker image
version: '3.1'
services:
mariadb:
image: mariadb:10.8
restart: always
ports:
- 3306:3306
volumes:
- ./mariadb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_PASSWORD=admin
- MYSQL_USER=admin
- MYSQL_DATABASE=test
- MYSQL_TCP_PORT=3306
phpMyAdmin:
image: phpmyadmin
restart: always
ports:
- 8080:80
environment:
- PMA_ARBITRARY=1
@hasinhayder
Copy link
Author

create a folder named mariadb in the same folder where docker-compose.yml is

this will act as your data directory

you can access phpmyadmin in browser as http://localhost:8080

default server name = mariadb
user: admin
password: admin

@hasinhayder
Copy link
Author

you can also connect to this docker image from your terminal as

mysql -u root -p -h 127.0.0.1

@hasinhayder
Copy link
Author

or simply run docker ps - you will see the image name as something like mariadb_mariadb_1

then you can log into the shell as

docker exec -it mariadb_mariadb_1 bash

@hasinhayder
Copy link
Author

hasinhayder commented Jul 2, 2022

if MariaDB is running on another port, for example 3307, you can configure phpMyAdmin to connect on port 3307 like this

version: '3.1'

services:
  mariadb:
    image: mariadb:10.8
    restart: always
    ports:
      - 3307:3306
    volumes:
      - ./mariadb:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_PASSWORD=admin
      - MYSQL_USER=admin
      - MYSQL_DATABASE=test
      - MYSQL_TCP_PORT=3306
  phpMyAdmin:
    image: phpmyadmin
    restart: always
    ports:
      - 8080:80
    environment:
      - PMA_PORT:3307
      - PMA_ARBITRARY=1

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