Docker Redis Connection refused

前端 未结 5 1285
情书的邮戳
情书的邮戳 2021-01-31 04:59

I\'m trying to access Redis server through the code and it\'s not connecting. But if i bash to the redis container i can access the redis-cli.

docker-compose.yml looks l

5条回答
  •  耶瑟儿~
    2021-01-31 05:26

    docker-compose.yml Config

        lnmp-redis:
        image: yahuiwong/lnmp:redis3.2.9
        hostname: lnmp-redis-v3
        ports:
            - "63789:63789"
    

    Example

        $redis = new \Redis();
    var_dump($redis);
    try {
        $redis->connect('lnmp-redis-v3', 63789);
        var_dump($redis->keys("*"));
    } catch (\Exception $e) {
        var_dump($e->getMessage())  ;
    }
    

提交回复
热议问题