skip to Main Content

I want to monitor redis running in webdis docker container.
I use telegraf which collects redis stats but, telegraf is installed on host machine and it cannot connect to redis as it is running inside docker on 6379 port.

I tried to map docker port 6379 on which redis is running inside docker with hosts 6379 port so telegraf can listen to redis metrices, but telegraf cannot listen as connection breaks.
when I use telnet on host, I get connection closed by foreign host error.

telnet 127.0.0.1 6379
Trying 127.0.0.1…
Connected to 127.0.0.1.
Escape character is ‘^]’.
Connection closed by foreign host.

Also, I am able to connect to webdis port on host machine, which is running on port 7379 inside wedis container.

To start webdis I am using following command : "docker run -d -p 8080:7379 -p 6379:6379 webdis"

Further to debug, I checked that redis inside webdis container is running on interface 127.0.0.1:6379
I checked that it should be running on 0.0.0.0:6379 in-order for port mapping to work properly.

How can I run redis inside webdis image on 0.0.0.0:6379?
Is there any other way I can monitor redis server running inside webdis container?
I tried to start redis-server inside webdis container by binding it to 0.0.0.0 using redis.conf file, but it still binds with 127.0.0.1

2

Answers


  1. To which docker image are you refering. Is it this one? https://github.com/anapsix/docker-webdis/

    If yes, when checking the Dockerfile, it does not include redis itself but in docker-compose.yaml there is a redis service include. This one does not expose ports which you need to connect to redis from outside of the container.

    You need to change redis service to the following:

    ...
    redis:
      image: 'anapsix/redis:latest'
      ports: 
          - '6379:6379'
    
    Login or Signup to reply.
  2. I have this problem recently ago and I solve it.

    webdis.Dockerfile

    FROM nicolas/webdis:0.1.19
    EXPOSE 6379
    EXPOSE 7379
    RUN sed -i "s/127.0.0.1/0.0.0.0/g" /etc/redis.conf
    

    docker-compose.yaml

    version: "3.8"
    services:
      webdis:
        build:
          context: .
          dockerfile: webdis.Dockerfile
        image: webdis_with_redis_expose
        container_name: webdis
        restart: unless-stopped
        ports:
          - "6379:6379"
          - "7379:7379"
    

    then execute docker-compose up

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search