mysql在docker上的安装配置
参考:
- Connect to container create by docker-compose:https://forums.docker.com/t/connect-to-container-create-by-docker-compose/44682
- How to Create a MySql Instance with Docker Compose:https://medium.com/@chrischuck35/how-to-create-a-mysql-instance-with-docker-compose-1598f3cc1bee
- phpmyadmin/phpmyadmin:https://hub.docker.com/r/phpmyadmin/phpmyadmin/
- docker 部署 mysql + phpmyadmin 3种方法:https://blog.csdn.net/Gekkoou/article/details/80897309
- 利用 Docker 架起 phpMyAdmin + MySQL (MAC):https://ithelp.ithome.com.tw/articles/10200754?sc=pt
- Docker 安裝 Mysql + Phpmyadmin:http://www.andrewchen.tw/2017/05/05/20170505_NOTE_DOCKER_MYSQL/
- Docker安装Mysql管理工具Phpmyadmin:https://xu3352.github.io/docker/2017/12/27/install-phpmyadmin-with-docker
配置网络-容器间互联
docker network create -d bridge mysql_network
使用docker-compose
docker-compose常用命令
docker-compose service的启动、运行及删除
docker-compose up -d //创建并后台启动
docker-compose stop //停止
docker-compose start //启动
docker-compose ps //查看
docker-compose down --rmi all --remove-orphans //删除服务、并删除生成的镜像和容器
创建网络 net-mysql
docker network create -d bridge network_mysql
创建容器mysql
cd /var/www/mysql
docker run -d \
--restart always \
--name my-mysql \
--network network_mysql \
-e MYSQL_USER=luowei \
-e MYSQL_PASSWORD=xxxx \
-e MYSQL_ROOT_PASSWORD=xxxxxx \
-v $PWD/conf:/etc/mysql \
-v $PWD/mydata:/var/lib/mysql \
-p 3306:3306 \
mysql:5.7
docker run --rm -d \
--name my-mysql \
-e MYSQL_USER=luowei \
-e MYSQL_PASSWORD=xxxx \
-e MYSQL_ROOT_PASSWORD=xxxxxx \
-v $PWD/conf:/etc/mysql \
-v $PWD/mydata:/var/lib/mysql \
-v $PWD/log:/var/log \
-p 3306:3306 \
--network network_mysql \
mysql:5.7
创建容器 my-phpmyadmin
# docker cp fdafd3ecc26f:/etc/phpmyadmin/config.user.inc.php /Users/luowei/projects/My_Docker/phpmyadmin/data/config.user.inc.php
# docker cp fdafd3ecc26f:/usr/local/etc/php/conf.d/php-phpmyadmin.ini /Users/luowei/projects/My_Docker/phpmyadmin/data/php-phpmyadmin.ini
docker run -d \
--name my-phpmyadmin \
--network network_mysql \
-e MYSQL_USER=luowei \
-e MYSQL_PASSWORD=xxxx \
-e MYSQL_ROOT_PASSWORD=xxxxxx \
-e PMA_HOST=my-mysql \
-p 31000:80 \
phpmyadmin/phpmyadmin:4.9
docker run --rm \
--name my-phpmyadmin \
--network network_mysql \
-e MYSQL_USER=luowei \
-e MYSQL_PASSWORD=xxxx \
-e MYSQL_ROOT_PASSWORD=xxxxxx \
-e PMA_HOST=my-mysql \
-v $PWD/log:/var/log \
-p 31000:80 \
phpmyadmin/phpmyadmin:4.9