保留镜像

root@hello:~# docker pull redis:latestlatest: Pulling from library/redisa2abf6c4d29d: Already exists c7a4e4382001: Pull complete 4044b9ba67c9: Pull complete c8388a79482f: Pull complete 413c8bb60be2: Pull complete 1abfd3011519: Pull complete Digest: sha256:db485f2e245b5b3329fdc7eff4eb00f913e09d8feb9ca720788059fdc2ed8339Status: Downloaded newer image for redis:latestdocker.io/library/redis:latestroot@hello:~# root@hello:~# docker save > redis.tar redis:latest root@hello:~# root@hello:~# ll redis.tar -rw-r--r-- 1 root root 116304384 Mar 30 07:30 redis.tarroot@hello:~#

导入镜像

root@hello:~# docker load -i redis.tar 2edcec3590a4: Loading layer [==================================================>]  83.86MB/83.86MB9b24afeb7c2f: Loading layer [==================================================>]  338.4kB/338.4kB4b8e2801e0f9: Loading layer [==================================================>]  4.274MB/4.274MB529cdb636f61: Loading layer [==================================================>]   27.8MB/27.8MB9975392591f2: Loading layer [==================================================>]  2.048kB/2.048kB8e5669d83291: Loading layer [==================================================>]  3.584kB/3.584kBLoaded image: redis:latest

创立目录,批改配置

root@hello:~# mkdir /data/redis -proot@hello:~# mkdir /data/redis/data -proot@hello:~# cp -p redis.conf /data/redis/root@hello:~# vim /data/redis/redis.conf

批改redis.conf配置文件:

次要配置的如下:

 bind 127.0.0.1 #正文掉这部分,使redis能够内部拜访

 daemonize no#用守护线程的形式启动

 requirepass thinekr #给redis设置明码

 appendonly yes #redis长久化  默认是no

 tcp-keepalive 300 #防止出现近程主机强制敞开了一个现有的连贯的谬误 默认是300

 启动容器

 root@hello:~# docker run -p 6379:6379 --name redis -v /data/redis/redis.conf:/etc/redis/redis.conf  -v /data/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yesa59d3137a3ade6ec05588e0895d2265aff0e81746ec1847553fef6bd4df59348root@hello:~#

测试

root@hello:~# sudo docker logs redis1:C 30 Mar 2022 07:36:59.712 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo1:C 30 Mar 2022 07:36:59.712 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=1, just started1:C 30 Mar 2022 07:36:59.712 # Configuration loaded1:M 30 Mar 2022 07:36:59.713 * monotonic clock: POSIX clock_gettime                _._                                                             _.-``__ ''-._                                                   _.-``    `.  `_.  ''-._           Redis 6.2.6 (00000000/0) 64 bit  .-`` .-```.  ```\/    _.,_ ''-._                                   (    '      ,       .-`  | `,    )     Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379 |    `-._   `._    /     _.-'    |     PID: 1  `-._    `-._  `-./  _.-'    _.-'                                    |`-._`-._    `-.__.-'    _.-'_.-'|                                   |    `-._`-._        _.-'_.-'    |           https://redis.io         `-._    `-._`-.__.-'_.-'    _.-'                                    |`-._`-._    `-.__.-'    _.-'_.-'|                                   |    `-._`-._        _.-'_.-'    |                                    `-._    `-._`-.__.-'_.-'    _.-'                                         `-._    `-.__.-'    _.-'                                                 `-._        _.-'                                                         `-.__.-'                                               1:M 30 Mar 2022 07:36:59.714 # Server initialized1:M 30 Mar 2022 07:36:59.714 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.1:M 30 Mar 2022 07:36:59.715 * Ready to accept connectionsroot@hello:~#root@hello:~# redis-cli -h 3.7.191.194 -p 63793.7.191.194:6379> auth thinkerOK3.7.191.194:6379> pingPONG3.7.191.194:6379>

https://www.oiox.cn/

https://www.chenby.cn/

https://cby-chen.github.io/

https://weibo.com/u/5982474121

https://blog.csdn.net/qq_3392...

https://my.oschina.net/u/3981543

https://www.zhihu.com/people/...

https://segmentfault.com/u/hp...

https://juejin.cn/user/331578...

https://space.bilibili.com/35...

https://cloud.tencent.com/dev...

https://www.jianshu.com/u/0f8...

https://www.toutiao.com/c/use...

CSDN、GitHub、知乎、开源中国、思否、掘金、简书、腾讯云、哔哩哔哩、今日头条、新浪微博、集体博客、全网可搜《小陈运维》