我的 gitlab-ci.yml 看起來像這樣:stage: functional_test only: - develop - master - merge_requests services: - redis:latest - docker:18.06.2-dind variables: PHOTON_ENV: development DOCKER_HOST: tcp://localhost:2375 REDIS_HOST: redis REDIS_URL: redis://redis:6379/0我連接redis的python代碼如下所示:self._redis = redis.Redis(host=_host, port=_port, db=_db, decode_responses=True)_host = 'redis'_port = 6379_db = 0但是,每次我嘗試這段代碼時,都會出現(xiàn)這個錯誤: File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 772, in execute_command403 connection = pool.get_connection(command_name, **options)404 File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 994, in get_connection405 connection.connect()406 File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 497, in connect407 raise ConnectionError(self._error_message(e))408 redis.exceptions.ConnectionError: Error -2 connecting to redis:6379. Name or service not known.
在 gitlab ci 管道中,如何使用 python 連接到 redis 服務?
12345678_0001
2022-10-11 16:03:55