cat > /srv/mysql/my.cnf <<EOF
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Custom config should go here
!includedir /etc/mysql/conf.d/

default_authentication_plugin= mysql_native_password
EOF
docker run \
  --name mysql8 \
  -p 3306:3306 \
  -v /srv/mysql/data:/var/lib/mysql \
  -v /srv/mysql/log:/var/log/mysql \
  -v /srv/mysql/my.cnf:/etc/mysql/my.cnf:rw \
  -e MYSQL_ROOT_PASSWORD=$PassWord \
  --restart=always \
  -d mysql:8.0.16
cat > /srv/redis/redis.conf <<EOF
#注释掉这部分,这是限制redis只能本地访问
bind 0.0.0.0
#默认yes,开启保护模式,限制为本地访问
protected-mode no
#默认no,改为yes意为以守护进程方式启动,可后台运行,除非kill进程,改为yes会使配置文件方#式启动redis失败
daemonize no
#redis持久化(可选)
appendonly no
#设置密码
requirepass $PassWord
EOF
docker run -p 6379:6379 --name redis \
 -v /srv/redis/redis.conf:/etc/redis/redis.conf  \
 --restart=always \
 -d redis redis-server /etc/redis/redis.conf 
apt-get install mysql-client
apt-get install redis-tools
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐