Create Docker image with fritzconnection

Hello community,

I am trying to find a way to create a Docker image having python as well as fritzconnection ( fritzconnection documentation — fritzconnection 1.10 documentation) installed in a slim OS (like debian:bullseye-slim or alpine:latest) to have a Docker Container for easily monitoring the FritzBox data within a database (like InfluxDB)

My first attempts did not work so far.

FROM debian:bullseye-slim

#User information, e.g. root

#Required packages: python and fritzconnection
RUN apt-get -q update && apt-get -q install python3-pip gcc bash -y
RUN pip3 install fritzconnection

#Create logfile directory
ADD configs/ /etc/fritzconnection/configs

#Port to be used
EXPOSE 25826

CMD start

The database (e.g. InfluxDB) should be setup in a separate container. In best case the connection for FritzBox Login data as well as InfluxDB access can be stored in a *.cfg file or similar.

Maybe you can help? Is there a good way to share the current draft code to be adapted (e.g. should I create a Docker Hub Repository)?

and what was the problem. Do you have any error message?

Thank you for replying @rimelek :slight_smile:

The bad news is: there is no error message…

Removing intermediate container affee0cc51ed
 ---> c4bfad44587b
Step 5/8 : RUN pip3 install fritzconnection envtpl
 ---> Running in bc60b782bb27
Collecting fritzconnection
  Downloading fritzconnection-1.10.3.tar.gz (45 kB)
Collecting envtpl
  Downloading envtpl-0.7.2-py3-none-any.whl (4.7 kB)
Collecting Jinja2~=3.0
  Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (26 kB)
Collecting requests>=2.22.0
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2022.9.24-py3-none-any.whl (161 kB)
Building wheels for collected packages: fritzconnection
  Building wheel for fritzconnection ( started
  Building wheel for fritzconnection ( finished with status 'done'
  Created wheel for fritzconnection: filename=fritzconnection-1.10.3-py3-none-any.whl size=58813 sha256=bfb75cdbaa29d07ceeda50b7a3e4a66eb3a189375f24527875b6566824bb6547
  Stored in directory: /root/.cache/pip/wheels/dc/ed/e1/ffd214e4f046870d40cb15d18719606e6d961694beb528034e
Successfully built fritzconnection
Installing collected packages: urllib3, MarkupSafe, idna, charset-normalizer, certifi, requests, Jinja2, fritzconnection, envtpl
Successfully installed Jinja2-3.1.2 MarkupSafe-2.1.1 certifi-2022.9.24 charset-normalizer-2.1.1 envtpl-0.7.2 fritzconnection-1.10.3 idna-3.4 requests-2.28.1 urllib3-1.26.12
Removing intermediate container bc60b782bb27
 ---> a0c99c084dd9
Step 6/8 : ADD configs/ /etc/collectd/configs
 ---> 1986ff19f1ad
Step 7/8 : EXPOSE 25826
 ---> Running in e53044042cb3
Removing intermediate container e53044042cb3
 ---> 14188947f00a
Step 8/8 : CMD start
 ---> Running in 798de5fc754d
Removing intermediate container 798de5fc754d
 ---> f06d3a190c57
Successfully built f06d3a190c57

The container is now showing in the Portainer list.

Is there any possibility to maybe use just

FROM python:xyz

and to setup the InfluxDB connection as well as the FritzBox script within this Dockerfile and the linked config?

Your image just builds fine. But I doubt your CMD actually does what you think it does… How is start related to fritzconnection, and how does it actualy start it?

You didn’t start any container just built the image. You have to start a container from it. What happens when you start it? Did you expect to start a container because of the last line?

CMD start

To be honest, I think here my knowledge gap finds its beginning :slight_smile: after completion of the setup and installation of the image,

  • would a e.g. python script be the „only thing required“ to start the logic within the container via start command?
  • Where to put this logic as best practice?
  • How do I decide if a whole system image (e.g. alpine or buster) is necessary or if I also could just chose the python base image for my intention?

My goal is to have a python3 container that can be configured to easily setup the fritz-connection module, the connection information of the FritzBox and the influx DB connection to write the data to a defined database. (for monitoring the FritzBox and such information like data traffic as it was done by FritzCollectd running on python 2.7)

What start command? I still don’t know what “start” in your CMD is.

I don’t understand this question.

It is easier to use a python image for a Python application than installing a specific python version during docker build.

Sometimes questions are the better answers :slight_smile: with your questions, I have found out my issue: Thought Knots…to sum up: the container building is correct but no program logic is triggered. So I need to write some python code doing the program flow “fill the Influx database with information grabbed from the Fritzbox” which needs to be triggered within the start CMD.