Docer搭建redis

經過docker-compose能夠方便的搭建redis用於測試
以下是具體內容redis

下載鏡像docker

docker pull redis

建立目錄存放配置文件測試

mkdir -p xxx/redis/conf

從官網獲取配置文件ui

wget http://download.redis.io/redis-stable/redis.conf

docker-compose.yml文件內容code

version: '3.1'
services:
    redis:
      image: redis:latest
      container_name: redis
      ports:
        - "6379:6379"
      volumes:
        - /data/redis/conf/redis.conf:/etc/redis/redis.conf 
      command: redis-server /etc/redis/redis.conf 
      privileged: true

啓動server

docker-compose up -d

鏈接確認get

docker-compose exec redis redis-cli
127.0.0.1:6379> keys *

到此在本地使用已經OK了,可是要讓redis外網能夠訪問須要修改redis.conf配置文件io

容許外網訪問修改redis.conf文件docker-compose

  • 1table

    bind 127.0.0.1

    改成

    #bind 127.0.0.1
  • 2

    protected-mode yes

    改成

    protected-mode no

設置訪問口令

# requirepass foobared

改成

requirepass yourpassword

從新啓動即可之外網訪問了

相關文章
相關標籤/搜索