启动mysql
`docker run --name mysql -v ~/volume_docker/mysql:/var/lib/mysql -e MYSQL_ROOT_HOST=127.0.0.1 -e MYSQL_ROOT_PASSWORD=112233 -p 3306:3306 -d mysql`
```
1. -v ~/volume_docker/mysql:/var/lib/mysql 数据挂载目录,如果需要给配置文件 可以 -v /yourconfig:/etc/mysql/conf.d
2 . -e MYSQL_ROOT_HOST 增加这个环境变量可以允许root远程登录,127.0.0.1是指宿主机,可以使用 %
其他docker基本参数,不做赘述。上两个链接
```
启动redis-cluster
这里一个sh脚本,抄自国外一个大佬
```
#------------ bootstrap the cluster nodes --------------------
start_cmd='redis-server --port 6379 --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes'
#redis镜像版本
redis_image='redis:latest'
network_name='redis_cluster_net'
docker network create $network_name
echo $network_name " created"
#---------- create the cluster ------------------------
# 这里启动了6379到6384 端口,一共6个redis,三主三从
for port in `seq 6379 6384`; do \
docker run -d --name "redis-"$port -p $port:6379 --net $network_name $redis_image $start_cmd;
echo "created redis cluster node redis-"$port
done
cluster_hosts=''
for port in `seq 6379 6384`; do \
hostip=`docker inspect -f '{{(index .NetworkSettings.Networks "redis_cluster_net").IPAddress}}' "redis-"$port`;
echo "IP for cluster node redis-"$port "is" $hostip
cluster_hosts="$cluster_hosts$hostip:6379 ";
done
echo "cluster hosts "$cluster_hosts
echo "creating cluster...."
echo 'yes'|docker run -i --rm --net $network_name $redis_image redis-cli --cluster create $cluster_hosts --cluster-replicas 1;
```