Y
Y
yativ_sobb2022-04-07 10:44:56
Docker
yativ_sobb, 2022-04-07 10:44:56

Container can't access redis host?

bot:
    restart: always
    network_mode: bridge
    build:
      context: .
      dockerfile: dockerfile
    depends_on:
      - cache
cache:
    image: redis:6.2-alpine
    restart: always
    command: redis-server --save 20 1 --loglevel warning --requirepass [email protected] --loglevel warning
    ports:
      - 6379:6379
    volumes: 
      - cache:/data


I can't connect to redis container from node container, I tried these addresses 172.17.0.1, localhost, 127.0.0.1

OS: Ubuntu
docker version: 19.03.13

If I run on MAC it works but there I use host.docker.internal , but on linux, it doesn't work for obvious reasons.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yativ_sobb, 2022-04-07
@yativ_sobb

Решил короче так, добавил
links:
- cache:host.docker.cache
в container bot

Александр Карабанов, 2022-04-07
@karabanov

Укажи имя, а не IP адрес. В твоём случае имя будет cache
127.0.0.1 - вообще нет смысла использовать, так как у каждого контейнера свой loopback интерфейс.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question