Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 从Cloud Run Emulator本地连接到Docker(Redis)中运行的容器_Google Cloud Platform_Redis_Google Cloud Run_Google Cloud Code_Google Cloud Intellij - Fatal编程技术网

Google cloud platform 从Cloud Run Emulator本地连接到Docker(Redis)中运行的容器

Google cloud platform 从Cloud Run Emulator本地连接到Docker(Redis)中运行的容器,google-cloud-platform,redis,google-cloud-run,google-cloud-code,google-cloud-intellij,Google Cloud Platform,Redis,Google Cloud Run,Google Cloud Code,Google Cloud Intellij,我正在使用Intellij(PyCharm)的云代码插件制作本地云运行服务,但本地部署的服务无法连接到Docker中运行的redis实例: redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused. 我可以从pythonshell连接到本地运行的redis实例,只是在minikube/docker中运行的云运行服务似乎无法连接到它 有什么想法吗 编辑,因为人们建议完全

我正在使用Intellij(PyCharm)的云代码插件制作本地云运行服务,但本地部署的服务无法连接到Docker中运行的redis实例:

redis.exceptions.ConnectionError: Error 111 connecting to 127.0.0.1:6379. Connection refused.
我可以从pythonshell连接到本地运行的redis实例,只是在minikube/docker中运行的云运行服务似乎无法连接到它

有什么想法吗


编辑,因为人们建议完全不相关的帖子-本地运行的云运行实例使用Docker和Minikube运行,并由Intellij的云代码自动配置。我怀疑intellij的云代码将云运行实例置于一个无法访问MacOS localhost上运行的服务(但可以访问Internet)的环境中,这就是我在文章中标记这些特定项目的原因。请将建议限制为考虑到这些项目的建议。

如果您使用以下方式检查Docker网络:

docker network list
您将看到一个名为
cloudrundevinternal
的网络。您需要将Redis容器连接到该网络。为此,请运行此命令(此指令假定您的容器名称为some redis):

仔细检查您的容器是否已连接到网络:

docker network inspect cloud-run-dev-internal
然后使用容器名称连接到Redis主机:

import redis
...

redis_host = os.environ.get('REDISHOST', 'some-redis')
redis_port = int(os.environ.get('REDISPORT', 6379))
redis_client = redis.StrictRedis(host=redis_host, port=redis_port)

请显示有关如何连接到Redis实例的信息。另外,Dockerfile和依赖项上有什么内容?你的帖子有一个非常相似的帖子,这可能会有帮助,谢谢,但这一点都不相似。本地运行的云运行实例使用docker和minikube运行,并由Intellij的云代码自动配置。我怀疑intellij的云代码将云运行实例置于无法访问MacOS localhost上运行的服务的环境中,这就是我在文章中标记这些特定项目的原因。谢谢,这正是我所需要的。docker network inspect命令特别有用,因为网桥使用本地网络地址空间(不是127.0.0.1)。
import redis
...

redis_host = os.environ.get('REDISHOST', 'some-redis')
redis_port = int(os.environ.get('REDISPORT', 6379))
redis_client = redis.StrictRedis(host=redis_host, port=redis_port)