1. mysql
安装
获取镜像
docker pull mysql:8.0.30
创建文件挂载目录
创建容器并运行
docker run -p 3306:3306 --name mysql3306 \
-v /home/docker/mysql8/log:/var/log/mysql \
-v /home/docker/mysql8/data:/var/lib/mysql \
-v /home/docker/mysql8/mysql-files:/var/lib/mysql-files \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:8.0.30 \
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
//旧,运行有问题
docker run -p 3306:3306 --name mysql3306 \
-v /home/docker/mysql8/log:/var/log/mysql \
-v /home/docker/mysql8/data:/var/lib/mysql \
-v /home/docker/mysql8/conf:/etc/mysql \
-v /home/docker/mysql8/mysql-files:/var/lib/mysql-files \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:8.0.30 \
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
进入容器内部
docker exec -it mysql3306 bash
mysql开启远程链接
use mysql;update user set host="%" where user="root";//刷新权限
flush privileges;
问题
启动不起来
查看容器日志
docker logs mysql3306
mysqld: Can't read dir of '/etc/mysql/conf.d/'
文件挂载时/etc/mysql/conf.d/
出问题,版本问题
2. Redis
2.1 安装
下载镜像
docker pull reids:6.2.7
创建挂载文件
//在/home/docker目录下
mkdir redis6/conf -p
touch redis.conf
** 创建容器并运行**
docker run -p 6379:6379 --name redis6379 \
-v /home/docker/redis/data:/data \
-v /home/docker/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis:6.2.7 \
redis-server /etc/redis/redis.conf