Trouble connecting to datasource in dockerized environment

I’m starting up my environment with docker compose. I have an service providing a REST api to mongodb. When I try to connect to the service from the localhost:3000 url, I get a 502 error, noresolvable.

My docker compose file:

services:
  process_iq:
    build:
      context: ./
      target: chef-process_iq
    expose:
      - "26300"
      - "27018"
    ports:
      - "27018:27018"
    restart: no

    environment:
      - HTTP_PROXY
      - HTTPS_PROXY
      - "NATS_URL=nats://nats:4222"
    depends_on:
      - nats
      - mongodb
      
   grafana:
    image: grafana/grafana
    container_name: grafana
    ports:
      - 3000:3000
    restart: unless-stopped
    environment:
      - HTTP_PROXY
      - HTTPS_PROXY
      - GF_INSTALL_PLUGINS=yesoreyeram-infinity-datasource
    volumes:
      - /tmp/grafana:/etc/grafana/provisioning/datasources
      - grafana-storage:/var/lib/grafana
      

Query url executed from the plugin web page that gives the error:
(error getting data frame. 502 notresolvable)

http://process_iq:27018/spectrogram

I can access the url successfully from the browser as:

http://localhost:27018/spectrogram

I can successfully execute the query from inside the grafana container (terminal):

curl -X ‘GET’ -H ‘Accept: application/json;q=0.9,text/plain’ ‘http://process_iq:27018/spectrogram’

I’ve run out of ideas as to why the plugin won’t successfully connect to the server.

That’s correct, but you have defined http proxy env variables. So can you execute the same curl via that http proxy?

So, the command:

curl -x $HTTP_PROXY http://process_iq:27018/spectrogram
generates the same notresolvable error, so that’s progress.

So the proxy is set so that grafana can download the plugin. How do I cause it disregard the proxy in this case?

Proxy is outside your docker network, so it doesn’t have idea how to resolve that name, which is resolveable only in docker network.

Use NO_PROXY env variable and exclude that datasource hostname from proxying. It must be direct connection, without proxy.