Unable to send data via http while running within a docker container

Hello all.

I have a python script that collects data and is able to send the data via http request to my influxdb. It works fine, UNTIL I try to run the same script within the container. I get a 204 status code, but when I try to view the data in real time (every 5 seconds via Grafana) no data shows up… but if I go back to running the python script outside of the docker container, it runs fine and I can see the data. Has anyone else had this problem? Thanks to all of those who reply in advance.

Can you share your Python script and the command you use to run it: both outside and inside the container

Here is the code:

… I run it the same outside the container and inside it. python3 nameoffile.py

import requests

class HttpProtocolHandler:

    def send(self, datapoints):
        print("DATAPOINTS:", flush=True)
        print(datapoints, flush=True)
        host = 'myhostnamehere'
        port = '8086'
        server = 'http://' + host + ':' + port + '/'
        database = 'streaming_test'
        api_add_datapoint = server + 'write?db=' + database + '&precision=ms'
            r = requests.post(api_add_datapoint, data=datapoints, auth=('user', 'password'), timeout=3)
        except requests.exceptions.ConnectionError:
            r.status_code == 'Connection Refused'

Can you provide the docker container run command, please?

Is InfluxDB on a machine, VM, or container; and is it’s hostname available on your network or only via Docker (Kubernetes/Compose?)

Docker command: docker run -v /dev/data-streaming/CANable:/dev/data-streaming/CANa ble --network host --privileged stream-data

InfluxDB is running on a locally hosted server of ours. The hostname is available on our network. We still get a ‘204 No content’ response in both cases… it’s just that when we run it inside the container no data is actually being sent it seems.