I have an app running that uses influxdb, chronograf (a webUI admin interface for influx), and grafana (a graph UI interface for influx).
My docker-compose fill brings up all 3 as services and uses version 3:
version: '3'
services:
grafana:
image: grafana/grafana
container_name: "grafana"
volumes:
- ${GRAFANA_DATA_PATH}:/var/lib/grafana
ports:
- "3000:3000"
networks:
- influxdb
influxdb:
image: influxdb:1.4.3-alpine
container_name: "influxdb"
volumes:
- ${INFLUXDB_DATA_PATH}:/var/lib/influxdb
ports:
- "8086:8086"
networks:
- influxdb
chronograf:
image: chronograf:1.4.0-alpine
container_name: "chronograf"
volumes:
- ${CHRONOGRAF_DATA_PATH}:/var/lib/chronograf
ports:
- "8888:8888"
networks:
- influxdb
entrypoint:
- chronograf
- --influxdb-url=http://influxdb:8086
networks:
influxdb:
Everything seems to work ok except that when I log into grafana (on port 3000), and go to connect a data source (influxdb running on 8086), it will not work unless I use the server's public IP address.
None of these work:
- "http://localhost:8086"
- "http://127.0.0.1:8086"
- "http://influxdb:8086"
However this works:
- "http://4.25.24.11:8086"
This is a problem because I don't want to expose port 8086 public - it just needs to be accessible by the other containers. This used to be accomplished using "links" but that is deprecated and I'm trying to figure out how to do it in docker version 3.
Interestingly, chronograf has no problem connecting to influxdb when it starts up (as you can see in the entry point):
--influxdb-url=http://influxdb:8086
Figured it out about 5 minutes after posting the question (It's specific to Grafana): change the "access" field in HTTP settings to "proxy" (instead of "direct").
Hopefully this might save someone some time:
If using docker's net: "host" (or docker compose 3, network_mode: "host"), you can use the direct setting because the container is sharing the network with the host.
However if using a named network (such as in the compose file above), you may need to use proxy any time you use the network name in a URL string.
i think you are wrong, from chronograf you can access influxdb with just influxdb because both services are on same network and influxdb is just a DNS record from chronograf. you can try this command to verify if the port is open on that host, if it says open then communication should work
docker-compose run chronograf nc influxdb 8086 -v
i would also add depends_on to your docker-compose.yml and the influxdb port doesnt have to be exposed to public, i would rather also use command instead of entrypoint
version: '3'
services:
grafana:
image: grafana/grafana
depends_on: [influxdb]
ports:
- "3000:3000"
networks:
- influxdb
influxdb:
image: influxdb:1.4.3-alpine
networks:
- influxdb
chronograf:
image: chronograf:1.4.0-alpine
depends_on: [influxdb]
ports:
- "8888:8888"
networks:
- influxdb
command:
- chronograf
- --influxdb-url=http://influxdb:8086
networks:
influxdb:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.