1. Downloadredis.confThe configuration,Official website to downloadRedis compressed package of the corresponding version.

2. Create a data directory and a configuration file directory and save the downloaded configuration file to the directory$pwd/conf

mkdir conf
mkdir data
Copy the code

3. Run the container

docker run -d -p 6379:6379 --restart always --name some-redis \
-v $PWD/conf/redis.conf:/etc/redis/redis.conf \
-v $PWD/data:/data \
redis redis-server /etc/redis/redis.conf \
--requirepass "123456" --appendonly yes
Copy the code
  • -dThe background
  • -p 6379:6379Port mapping between host and container
  • --restart alwaysAutomatic startup
  • --privileged=trueRoot in the Container has the real root permission
  • -v $PWD/conf/redis.conf:/etc/redis/redis.confMount the configuration file
  • -v $PWD/data:/dataData directory, the host directory to the left of the colon, and the container internal path to the right of the colon
  • --requirepassPassword can also be passedredis.confconfiguration
  • --appendonlyPersistence is also available throughredis.confconfiguration

4. Modify the configuration$pwd/conf/redis.conf

[root@database] [root@database] [root@database] [root@database] [root@database] [root@database] [root@database] [root@database] Port 6379 # redis daemonize no # daemonize no Protected -mode no # Default yes, enabling the protected mode will restrict local access bind 127.0.0.1 # comment out this section, which will restrict redis to local access onlyCopy the code

5. Restart the container to take effect

docker restart some-redis
Copy the code

The related documents

  • The configuration file a: www.cnblogs.com/metu/p/9609…
  • Visual interface: github.com/qishibo/Ano…