人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

Docker安裝官方Redis鏡像并啟用密碼認(rèn)證

發(fā)布日期:2022-03-14 14:11 | 文章來源:站長之家

參考:docker官方redis文檔

1.有特殊版本需求的可以查看redis鏡像tag版本

3.2.11, 3.2, 3 (3.2/Dockerfile)
3.2.11-32bit, 3.2-32bit, 3-32bit (3.2/32bit/Dockerfile)
3.2.11-alpine, 3.2-alpine, 3-alpine (3.2/alpine/Dockerfile)
4.0.9, 4.0, 4, latest (4.0/Dockerfile)
4.0.9-32bit, 4.0-32bit, 4-32bit, 32bit (4.0/32bit/Dockerfile)
4.0.9-alpine, 4.0-alpine, 4-alpine, alpine (4.0/alpine/Dockerfile)

2.選擇最新版latest

docker pull redis:latest
[root@localhost~]# docker pull redis:latest
latest: Pulling from library/redis
4d0d76e05f3c: Pull complete 
cfbf30a55ec9: Pull complete 
82648e31640d: Pull complete 
fb7ace35d550: Pull complete 
497bf119bebf: Pull complete 
89340f6074da: Pull complete 
Digest: sha256:166788713c58c2db31c41de82bbe133560304c16c70e53a53ca3cfcf35467d8a
Status: Downloaded newer image for redis:latest

3.啟動(dòng)容器并帶密碼

docker run --name redis-test -p 6379:6379 -d --restart=always redis:latest redis-server --appendonly yes --requirepass "your passwd"

-p 6379:6379 :將容器內(nèi)端口映射到宿主機(jī)端口(右邊映射到左邊)
redis-server –appendonly yes : 在容器執(zhí)行redis-server啟動(dòng)命令,并打開redis持久化配置
requirepass “your passwd” :設(shè)置認(rèn)證密碼
–restart=always : 隨docker啟動(dòng)而啟動(dòng)

4.查看容器

docker ps
[root@localhost~]# docker ps
CONTAINER ID    IMAGE           COMMAND         CREATED       STATUS       PORTS                     NAMES
a126ec987cfe    redis:latest       "docker-entrypoint.s…"  4 minutes ago    Up 4 minutes    0.0.0.0:6379->6379/tcp             redis-test
3645da72ece6    portainer/portainer    "/portainer"       7 days ago     Up 7 days      0.0.0.0:9000->9000/tcp             sharp_lovelace
118ba79de20a    hwdsl2/ipsec-vpn-server  "/opt/src/run.sh"    12 days ago     Up 12 days     0.0.0.0:500->500/udp, 0.0.0.0:4500->4500/udp  l2tp-vpn-server
848fdba6de60    kylemanna/openvpn     "ovpn_run"        12 days ago     Up 12 days     1194/udp, 0.0.0.0:1194->1194/tcp        openvpn
a273504f9646    mysql:5.6.38       "docker-entrypoint.s…"  8 weeks ago     Up 5 days      0.0.0.0:3306->3306/tcp             mysql5.6.38

redis容器的id是 a126ec987cfe

5.查看進(jìn)程

ps -ef|grep redis
[root@localhost~]# ps -ef|grep redis
polkitd 26547 26535 0 14:58 ?    00:00:00 redis-server *:6379
root   26610 26432 0 15:05 pts/0  00:00:00 grep --color=auto redis

6.進(jìn)入容器執(zhí)行redis客戶端

docker exec -it a126ec987cfe redis-cli -a 'your passwd'
[root@localhost~]# docker exec -it a126ec987cfe redis-cli -h 127.0.0.1 -p 6379 -a 'your passwd'
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:d3ebfc7feabc1290
redis_mode:standalone
os:Linux 3.10.0-693.21.1.el7.x86_64 x86_64
...

-h 127.0.0.1 :默認(rèn)不加為-h 127.0.0.1
-p 6379 :默認(rèn)不加為 -p 6379

或者連接的時(shí)候不帶密碼,如下:

[root@localhost ~]# docker exec -it a126ec987cfe redis-cli
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 'your passwd'
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> info
# Server
redis_version:4.0.9
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:d3ebfc7feabc1290
redis_mode:standalone
os:Linux 3.10.0-693.21.1.el7.x86_64 x86_64
arch_bits:64

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。

版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問服務(wù)

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部