First, make sure that the right environment, docker state has been running, the firewall is turned off (or ip and port accessible)
Second, download the image
1, image search
docker search redis
Since we are using the redis-3.2.11
So, go
https://hub.docker.com
version looking at
You can see, there is this version 3.2.11
2, Download image
docker pull redis:3.2.11
- View Mirror
docker images
3, start the container and configured to mount the directory
- Create Folder
mkdir -p /data/redis/data /data/redis/conf
-Conf placed redis.conf configuration file in the directory
3.1 conf file to download
Download redis.conf
redis.conf address
Enter the conf directory
cd conf/
Download the conf file
wget https://raw.githubusercontent.com/antirez/redis/3.0/redis.conf
If wget is not found, install wget components, and then download
Using a configuration file to start a container:
docker run -p 6379:6379 -v /data/redis/conf/redis.conf:/etc/redis/redis.conf -v /data/redis/data:/data --privileged=true --name redis-pro -d redis:3.2.11 --appendonly yes
- A way to start the configuration file (case)
docker run -p 6379:6379 -v /data/redis/conf/redis.conf:/etc/redis/redis.conf -v /data/redis/data:/data --privileged=true --name redis-pro -d redis:3.2.11 redis-server /etc/redis/redis.conf --appendonly yes
Parameter analysis:
-restart = Always -> boot container, container abnormal automatic restart
-d -> way to start the daemon container
-privileged = true -> elevate the container rights
-p 6379: 6379 -> bind host port
-v /data/redis/conf/redis.conf:/etc/redis/redis.conf -> mapping configuration file
-v / data / redis / data: / data -> map data directory
-name redis-pro -> specify The container name
-appendonly yes -> open data persistence
View container running
docker ps
Connection Test