K
K
keddad2020-04-28 11:41:25
Python
keddad, 2020-04-28 11:41:25

How to connect to docker radish with domain set in docker-compose?

Let's say I set something like this in docker-compose

ff_redis:
    restart: always
    hostname: redis
    image: redis:rc-alpine3.11
    environment:
        - REDIS_PASSWORD=mysweetredis


Then, using aioredis, I try to connect to this instance from the container that is defined in this file and is on this network:

async def connect_to_redis():
    db.client = await create_redis_pool("redis://redis", password="mysweetredis")


But I am getting an error:
ff_corecomp_1  |   File "/utils/redis.py", line 12, in connect_to_redis
ff_corecomp_1  |     db.client = await create_redis_pool("redis://redis", password="mysweetredis")
ff_corecomp_1  |   File "/usr/local/lib/python3.8/site-packages/aioredis/commands/__init__.py", line 188, in create_redis_pool
ff_corecomp_1  |     pool = await create_pool(address, db=db,
ff_corecomp_1  |   File "/usr/local/lib/python3.8/site-packages/aioredis/pool.py", line 58, in create_pool
ff_corecomp_1  |     await pool._fill_free(override_min=False)
ff_corecomp_1  |   File "/usr/local/lib/python3.8/site-packages/aioredis/pool.py", line 383, in _fill_free
ff_corecomp_1  |     conn = await self._create_new_connection(self._address)
ff_corecomp_1  |   File "/usr/local/lib/python3.8/site-packages/aioredis/connection.py", line 111, in create_connection
ff_corecomp_1  |     reader, writer = await asyncio.wait_for(open_connection(
ff_corecomp_1  |   File "/usr/local/lib/python3.8/asyncio/tasks.py", line 455, in wait_for
ff_corecomp_1  |     return await fut
ff_corecomp_1  |   File "/usr/local/lib/python3.8/site-packages/aioredis/stream.py", line 23, in open_connection
ff_corecomp_1  |     transport, _ = await get_event_loop().create_connection(
ff_corecomp_1  |   File "uvloop/loop.pyx", line 1914, in create_connection
ff_corecomp_1  | socket.gaierror: [Errno -3] Temporary failure in name resolution

It's like he can't resolve the domain. But the domain is clearly defined in the compose file! What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-04-28
@keddad

and so
redis://ff_redis

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question