0
votes

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

1

1 Answers

0
votes

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'