Hi all,
I am having a simple python script to fetch data from a table in InfluxDB installed in the local system. The deviceStatus.py script is as shown
import time
import sys
import influxdb
from influxdb import InfluxDBClient
client = InfluxDBClient(host='localhost', port=8086)
client.switch_database('deviceConfiguration')
results = client.query('SELECT (*) FROM "autogen"."FactoryConfig"')
points = results.get_points()
for point in points:
print(point['Connection'])
This script runs without any error and prints the IP Address (Connection) from the table FactoryConfig.
Now I want to create a docker image out of it. I wrote a Dockerfile that looks like this
FROM python:3.10.0b2-buster
WORKDIR /usr/src/app
COPY deviceStatus.py .
RUN pip install influxdb
CMD ["python", "./deviceStatus.py"]
This file compiles and creates a docker image named devicestatus. Now when I try to run the image with
sudo docker run devicestatus
it shows me an error on line 8 and complains that it cannot establish a new connection: [Errno 111] Connection refused
File "/usr/src/app/./deviceStatus.py", line 8, in <module>
results= client.query('SELECT (*) FROM "autogen"."FactoryConfig"')
I suppose it’s something to do with the port. I am not able to understand how can I expose the port if this is the problem. I need help regarding this issue.
Thanks in advance.
Cheers,
SD