Docker Method Steps for Installing MySQL and Redis

  • 2021-09-25 00:15:36
  • OfStack

This article is based on CentOS 7.3 system environment, MySQL and Redis installation and use

CentOS 7.3 Docker-ce

1. Install the MySQL image

(1) Pull the MySQL image


docker pull mysql:5.6

(2) Run and configure MySQL


docker run -p 3306:3306 --name xz_mysql
-v /data/mysql/conf:/etc/mysql/conf.g
-v /data/mysql/logs:/logs
-v /data/mysql/data:/var/lib/mysql
-e MYSQL_ROOT_PASSWORD=123456
-d mysql:5.6

(3) Enter the MySQL image container


docker exec -it xz_mysql /bin/bash

(4) Enter MySQL


mysql -uroot -p123456

2. Install the Redis image

(1) Pull the Redis image


docker pull redis:3.2

(2) Running and configuring Redis


docker run -p 6379:6379 --name xz_redis
-v /data/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf
-v /data/mysql/data:/data
-d redis:3.2 redis server /usr/local/etc/redis/redis.conf
--appendonly yes

(3) Create new configuration file redis. conf


cd /usr/local/etc/redis/redis.conf
vim redis.conf

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

aof-rewrite-incremental-fsync yes

(4) Enter the redis image container


docker exec -it xz_redis redis-cli

Related articles: