GithubHelp home page GithubHelp logo

Comments (10)

plague-doctor avatar plague-doctor commented on June 1, 2024 2

Oh, it is just easier for me to test different things.

ENTRYPOINT starts the container with parameters that cannot be overridden with CLI parameters.
CMD allows to do so.

In other words, when you specify:

ENTRYPOINT=/usr/bin/my-script.sh

then you cannot start your container with different parameter/script for example:

docker run -it my-docker-image /usr/bin/different-script.sh

The above example will start your container with /usr/bin/my-script.sh regardless what you specify as a starting parameter. In fact /usr/bin/different-script.sh will be interpreted as a parameter for your entrypoint.

When you use

CMD=["/usr/bin/my-script.sh"]

instead, you can override the starting point, so the above command will start your container with /usr/bin/different-script.sh.

When you specify both ENTRYPOINT and CMD, then whatever you put into the CMD becomes a parameter for your entrypoint. For example:

ENTRYPOINT=/usr/bin/my-script.sh
CMD=["parameter1", "parameter2"]

will be interpreted as:

/usr/bin/my-script.sh parameter1 parameter2

and you can override parameters with:

docker run -it my-docker-image parameter3

which will be corresponding to:

/usr/bin/my-script.sh parameter3

I hope this makes sense.

In my Dockerfile it can easily be moved to ENTRYPOINT. No problems with that ;-)

from frontend.

jpmens avatar jpmens commented on June 1, 2024 1

Thank you.

Closing this now, as it's been answered in owntracks/recorder#388

from frontend.

linusg avatar linusg commented on June 1, 2024

Curious - which recorder version did you previously run? I just updated my recorder here to latest and it still seems to work fine, but I'm using a slightly different (also traefik) setup.

from frontend.

plague-doctor avatar plague-doctor commented on June 1, 2024

I've got :latest as well, however when it started to fail, I have done some investigation ;-)
According to https://hub.docker.com/r/owntracks/recorder/tags it was 0.8.6-12. It has been updated 6 days ago to version 0.8.8...

from frontend.

jpmens avatar jpmens commented on June 1, 2024

I don't think we've changed anything which would cause this, @plague-doctor. What do you get when you invoke

curl http://a.b.c.d:8083/api/0/version

against the Recorder running in your container?

from frontend.

plague-doctor avatar plague-doctor commented on June 1, 2024

Ok, it looks like Recorder is binding to 127.0.0.1 instead to 0.0.0.0:

# netstat -ntlp
tcp        0      0 127.0.0.1:8083          0.0.0.0:*               LISTEN      13/ot-recorder

so I can nicely get response curl http://127.0.0.1:8083/api/0/version from within the container:

{"version":"0.8.8","git":"0.8.8-0-g0f86aa3af8"}

but not from other container (in my case from otr-frontend).
Recorder keeps ignoring env. variable OTR_HTTPHOST=0.0.0.0...

ot-recorder[9]: version 0.8.8 starting with STORAGEDIR=/store
ot-recorder[9]: connecting to MQTT ...
ot-recorder[9]: HTTP listener started on 127.0.0.1:8083

from frontend.

jpmens avatar jpmens commented on June 1, 2024

There's a OTR_HTTPHOST in recorder.conf in the container. What is that set to?

from frontend.

plague-doctor avatar plague-doctor commented on June 1, 2024

/config/recorder.conf is pretty much empty, except:

OTR_TOPICS="owntracks/#"

I can see it is set via env variables:

OTR_PASS=<edited>
OTR_HOST=<edited>
OTR_USER=<edited>
OTR_HTTPHOST=0.0.0.0
OTR_STORAGEDIR=/store
OTR_TOPIC=owntracks/#

but it is ignored...

I have noticed there is another version released (0.9.0) but the behavior is the same.

ot-recorder[10]: version 0.9.0 starting with STORAGEDIR=/store
ot-recorder[10]: connecting to MQTT 
ot-recorder[10]: HTTP listener started on 127.0.0.1:8083
ot-recorder[10]: Using storage at /store with precision 7
ot-recorder[10]: Subscribing to owntracks/# (qos=2)

from frontend.

plague-doctor avatar plague-doctor commented on June 1, 2024

It is misbehaving due to wrong entrypoint in the Docker file. Currently there entrypoint is:

#!/bin/sh

if ! [ -f ${OTR_STORAGEDIR}/ghash/data.mdb ]; then
    ot-recorder --initialize
fi

ot-recorder ${OTR_TOPIC}

which gives me the issue. The problematic bit is:

ot-recorder ${OTR_TOPIC}

which should be rather:

ot-recorder --http-host ${OTR_HTTPHOST:-0.0.0.0} --http-port ${OTR_HTTPPORT:-8083} $OTR_OPTIONS ${OTR_TOPICS:-owntracks/#}

I have came up with my Docker image (plaguedr/owntracks-recorder) which works as expected. In case you are interested, here it is:

Dockerfile:

FROM owntracks/recorder
LABEL maintainer="Plague Doctor"
LABEL name="owntracks-recorder"
LABEL architecture="x86_64"
COPY start.sh /usr/bin/start.sh
RUN apk update && apk add mosquitto-clients && \
    chmod 775 /usr/bin/start.sh
CMD ["start.sh"]
ENTRYPOINT []

and start.sh:

#!/bin/sh

while true; do
    if mosquitto_sub -h "$OTR_HOST" -u "$OTR_USER" -P "$OTR_PASS" -p 1883 -t '$SYS/broker/uptime' -C 1 > /dev/null 2>&1; then
        echo "MQTT is UP. Let's go!"
        break
    else
        echo "MQTT is DOWN. Waiting..."
        sleep 3
    fi
done

#sh /usr/sbin/entrypoint.sh

if ! [ -f ${OTR_STORAGEDIR}/ghash/data.mdb ]; then
    ot-recorder --initialize
fi

ot-recorder --http-host ${OTR_HTTPHOST:-0.0.0.0} --http-port ${OTR_HTTPPORT:-8083} $OTR_OPTIONS ${OTR_TOPICS:-owntracks/#}

from frontend.

jpmens avatar jpmens commented on June 1, 2024

That start.sh looks useful. Can you enlighten (i.e. teach) me why you switched from ENTRYPOINT to CMD?

from frontend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.