更新时间:2022-06-19 02:39:01
我怀疑问题是您正在尝试通过 localhost
而不是 parent-host
连接到Redis>.创建Jedis连接时,请确保通过 parent-host
连接到Redis.
I suspect the problem is that you are trying to connect to redis via localhost
rather than parent-host
. Make sure that you are connecting to redis via parent-host
when creating the Jedis connection.
-net = host
选项起作用的原因是,在这种情况下, localhost
将引用主机的IP,而不是容器的IP.
The reason --net=host
option works, is that in this case localhost
will refer to the IP of the host machine and not to that of the container.
此外,请确保容器内/etc/hosts
中的 parent-host
有一个实体.
Also, make sure that there is an enty for parent-host
in /etc/hosts
inside the container.