公用虚拟 IP (VIP)地址
42.159.156.115
内部 IP 地址
10.205.178.22
IP address for eth0: 10.205.178.22
IP address for docker0: 172.17.42.1
# requirepass foobared去掉注释,foobared改为自己的密码password
Download Link
https://www.sendspace.com/file/p1j6ac
Copy Link
Delete File Link
https://www.sendspace.com/delete/p1j6ac/9e70e7f78a89601d5658ccbdc4834c43
点击"Download Link"下方的连接,新页面复制“Click here to start download from sendspace:”的链接:https://fs10n2.sendspace.com/dl/03acafeeb8a1b799798666d55267a9cd/54a419057626bfac/p1j6ac/redis.conf(注意不要点击!如果点击请重新刷新页面,每次下载完都会变化)
sudo docker run -t -i -p 172.17.42.1:6379:6379 redis:latest /bin/bash
注意:这里的IP地址是docker的IP地址
cd /usr/local/bin
curl -o redis.conf https://fs10n2.sendspace.com/dl/03acafeeb8a1b799798666d55267a9cd/54a419057626bfac/p1j6ac/redis.conf
Note: 如果出现括号内的错误多试几次(Try more times if meet:curl: (6) Couldn't resolve host 'fs10n3.sendspace.com')
redis-server redis.conf
apt-get install redis-server
sudo docker ps -l
docker-enter 4fb1f04d706c
redis-cli -a password
set myvalue valueindocker
按Ctrl+D退出docker容器
redis-cli -h 172.17.42.1 -a password
get myvalue
"valueindocker"
iptables -t nat -A PREROUTING -m tcp -p tcp --dport 12345 -j DNAT --to-destination 172.17.42.1:6379
iptables -t nat -A POSTROUTING -m tcp -p tcp --dport 12345 -d 172.17.42.1 -j SNAT --to-source 42.159.156.115
iptables -A INPUT -p tcp --dport 12345 -j ACCEPT