Connecting to Redis running in Docker Container from Host machine

后端 未结 5 1661
别跟我提以往
别跟我提以往 2021-02-01 14:20

I see lots of people struggling with this, sort of feel like maybe there is a bug in the redis container image, and others seem to be chasing a similar problem.

I\'m usi

5条回答
  •  再見小時候
    2021-02-01 14:55

    Here are some instructions to make this work properly.

    Install Official Docker not Distro repo.

    curl -fsSL https://get.docker.com -o get-docker.sh
    sudo sh get-docker.sh
    systemctl enable docker ; systemctl start docker; systemctl status docker
    

    Refer to Install using the convenience script

    Connect to Redis container from host

    mkdir -p /etc/redis/
    chown -R 1000:1000 /etc/redis
    sudo docker run -d --name redis -p 6379:6379 --restart unless-stopped -v /etc/redis/:/data redis redis-server /data
    

    NOTE: The important part that is key to your solution is to have port expose (-p 6379:6379) to your docker host and route to container port. Refer to Redis Docker Documentation

    Install "redis-tools" in your docker host. Centos install redis via epel release.

提交回复
热议问题