Chirpstack-network-server using localhost from docker-compose

I am using docker-compose to run up a complete stack with postgres, mosquitto, redis CSAS and CSNS.
I have based the toml files for the CSAS and CSNS from the examples, and have noticed that the binds are different for the docker-compose setup for the API set up on ports 8000 and 8001 from the web site default setup of bind=“0.0.0.0:8000”. I have used the example from the docker-compose yml to use public_host=“chirpstack-network-server:8000” in CSNS toml, and public_host=“chirpstack-application-server:8001” in the CSAS toml. The stack uses several mosquitto brokers, redis, postgres, and all is well with these, all containers are running, and the stack is accessible from localhost:8080 for the GUI and appears to be running OK. I am getting LoRa packets from a connected gateway OK, and the join server is also running on 8003 OK, BUT I am seeing a connection request from the CSNS to 127.0.0.1:8001, a local host address. There is no setup in the toml files for such a connection, as the public_host settings as above have been selected in the toml files, so where is CSNS activating this localhost connection request from?

From docker-compose terminal output :-
chirpstack-network-server | time=“2021-07-06T14:11:54.6025111Z” level=warning msg=“creating insecure application-server client” server=“localhost:8001”
chirpstack-network-server | time=“2021-07-06T14:11:54.6029281Z” level=warning msg="[core] grpc: addrConn.createTransport failed to connect to {localhost:8001 localhost:8001 0 }. Err: connection error: desc = “transport: Error while dialing dial tcp 127.0.0.1:8001: connect: connection refused”. Reconnecting…

From CSAS toml file ;-
public_host=“chirpstack-application-server:8001”

Hi there, i stumbled on the same problem as you.
The problem is that you have to properly configure your servers.
First of all, you have to set the the proper host name in the application server toml file:
[application_server.api]
public_host="‘docker service name’:8001"

Then you go to the Web interface, and configure your Network Server with the proper host name
“docker service name”:8000

You only have to set the toml file for the application server, there is no such configuration for the network server. What is confusing is that the application server, automagically sets its own public host name and port in the network server when doing the handshake. If you set the wrong host name address in the Web Interface for the Network Server, then this handshake never happens and the Network Server never finds out how you configured the public_host attribute in the application server toml file, and defaults to localhost.