- Create a mysql volume
docker volume create mysql-volume
- Create a mysql container and pull mysql image from docker registry
docker run --name=nf-mysql -p 3306:3306 -v mysql-volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -pw -d mysql
- Test to create a database inside the container nf-mysql
docker exec -it nf-mysql bash
mysql -u root -p
mysql> CREATE DATABASE MYSQLTEST;
By default, MySQL restricts connection other than the local machine (here Docker container) for security reasons. So, to connect from the local machine, you have to change the connection restriction:
mysql> update mysql.user set host = ‘%’ where user=’root’;
- Create a phpmyadmin volume
docker volume create phpmyadmin-volume
- Create a phpmyadmin container
docker run --name nf-phpmyadmin -v phpmyadmin-volume:/etc/phpmyadmin/config.user.inc.php --link nf-mysql:db -p 82:80 -d phpmyadmin
- Access it from
http://localhost:82
orhttp://[::]:82