ntop / docker-ntop

A collection of Dockerfile for running ntop applications on Docker
315 stars 32 forks source link

can't connect to redis server without --net=host #2

Closed twpedersen closed 1 year ago

twpedersen commented 4 years ago
17/Jul/2020 18:48:28 [Redis.cpp:99] ERROR: Connection error [Connection refused]
17/Jul/2020 18:48:29 [Redis.cpp:148] ERROR: ntopng requires redis server to be up and running
17/Jul/2020 18:48:29 [Redis.cpp:149] ERROR: Please start it and try again or use -r
17/Jul/2020 18:48:29 [Redis.cpp:150] ERROR: to specify a redis server other than the default
Starting redis-server: redis-server.
17/Jul/2020 18:48:30 [Ntop.cpp:2236] Setting local networks to 127.0.0.0/8
17/Jul/2020 18:48:30 [Redis.cpp:99] ERROR: Connection error [Connection refused]
17/Jul/2020 18:48:31 [Redis.cpp:83] Redis has disconnected, reconnecting [remaining attempts: 14]
17/Jul/2020 18:48:31 [Redis.cpp:99] ERROR: Connection error [Connection refused]
17/Jul/2020 18:48:32 [Redis.cpp:83] Redis has disconnected, reconnecting [remaining attempts: 13]
17/Jul/2020 18:48:32 [Redis.cpp:99] ERROR: Connection error [Connection refused]
simonemainardi commented 3 years ago

I've tried to reproduce both w/ and w/o --net=host and it works.

It seems you are not starting Redis server which is a prereq for ntopng to operate. Are you using the official Dockerfile provided at https://github.com/ntop/docker-ntop/blob/master/Dockerfile.ntopng?

BTW, sorry for the late reply, we somehow missed this message.

aidanharris commented 3 years ago

Hello, can I ask why redis is inside of the docker container? This doesn't make a lot of sense to me. I built a container without redis but it required ugly hacks / workarounds because the ntopng package depends on redis. Fixing this probably requires packaging changes (one option could be to make an ntopng-core package without the redis dependency and install only this into the image and make an ntopng package for regular users of Debian/Ubuntu that depends on both redis-server and ntopng-core).

Here's my ugly Dockerfile if anyone is interested (it basically creates a fake redis-server package to satisfy the dependency):

FROM debian:buster
MAINTAINER ntop.org

ARG DEBIAN_MIRROR=deb.debian.org

ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN sed -i "s|deb.debian.org|${DEBIAN_MIRROR}|g" /etc/apt/sources.list && \
    apt-get update && \
    apt-get full-upgrade -y && \
    apt-get -y -q install equivs wget lsb-release gnupg && \
    wget -q http://apt-stable.ntop.org/buster/all/apt-ntop-stable.deb && \
    dpkg -i apt-ntop-stable.deb && \
    rm -fv *.deb && \
    apt-get clean all

RUN apt-get update && \
    cd /tmp && \
    apt-cache show redis-server | while read -r line; do [ -z "$line" ] && break; printf "%s\n" "$line"; done > redis-server && \
    sed -i 's|^Depends: .*|Depends: lsb-base (>= 3.2-14)|g' redis-server && \
    equivs-build redis-server && \
    dpkg -i ./redis-server_*.deb && \
    apt-mark manual redis-server && \
    apt-mark hold redis-server && \
    apt-get install -y ntopng && \
    apt-get remove -y equivs && \
    apt-get autoremove -y && \
    apt-get clean all && \
    rm -fv *

EXPOSE 3000

CMD ntopng