Reputation: 6179
As the doc. of the official InfluxDB image indicates, I'm creating an InfluxDB container as follows:
docker run --name=influxdb3 -p 8087:8087 influxdb
Yet, when I see its details, I get:
madmin’s-MacBook-Pro:sentinel-be jscherman$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f895d3e35c41 influxdb "/entrypoint.sh infl…" 9 seconds ago Up 7 seconds 8086/tcp, 0.0.0.0:8087->8087/tcp influxdb3
Why there are many ports being used? Why port 8086 given that I've never specified so? Moreover, if I try to query something to it, I get the following:
madmin’s-MacBook-Pro:sentinel-be jscherman$ curl -G http://localhost:8087/query --data-urlencode "q=CREATE DATABASE mydb"
curl: (52) Empty reply from server
madmin’s-MacBook-Pro:sentinel-be jscherman$ docker exec -ti influxdb3 /bin/bash
> root@f895d3e35c41:/# influx -port 8087
Failed to connect to http://localhost:8087: Get http://localhost:8087/ping: dial tcp 127.0.0.1:8087: connect: connection refused
Please check your connection settings and ensure 'influxd' is running.
root@f895d3e35c41:/#
I try to query something, then I get no response so from the container I try to connect to influx at port 8087 as I specified earlier but it doesn't exist. Is there any concept that I am missing? Is the query being done? Why doesn't it exist Influx at port 8087?
Upvotes: 0
Views: 3281
Reputation: 331
The standard port for InfluxDB is 8086 (have a look at the documentation).
If you want to use the port 8087 instead, the easiest way I believe is to start to docker container like this:
docker run --name=influxdb3 -p 8087:8086 influxdb
Upvotes: 1
Reputation: 158696
Docker images typically run servers. Often the port number is fixed within the Docker application or image: a server that provided an HTTP-based service might always serve it on port 80 or 8000 or 8080, for instance. In the case of InfluxDB it looks like its "standard" port number is 8086.
When you docker run -p
a container, you can specify a different port number, but you must remap it to the port number in the container that the server is listening on. If you want port 8087 on the host to reach port 8086 in the container, you'd specify
docker run --name=influxdb3 -p 8087:8086 influxdb
only changing the first port number.
A Dockerfile can declare what specific ports a server will listen on via an EXPOSE
directive. This isn't that useful in practice – an exposed port won't automatically be published out to the host, and you can publish ports that aren't exposed – but that's why your docker ps
command listed the standard port number as well.
Upvotes: 3