Currently I'm using the command docker run -p 6030-6042:6030-6042/tcp -p 6030-6040:6030-6040/udp --name taosd tdengine/tdengine
to start a TDengine server, and then connect it with taos
shell in another container with docker run --rm -it tdengine/tdengine taos -h <host ip>
. It connects ok, but when inserting data into a table, it causes error:
Welcome to the TDengine shell from Linux, Client Version:2.0.22.0
Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
taos> create database if not exists test;
Query OK, 0 of 0 row(s) in database (0.000638s)
taos> use test;
Database changed.
taos> create table if not exists tb1 (ts timestamp, n int);
Query OK, 0 of 0 row(s) in database (0.000880s)
taos> insert into tb1 values (now, 1);
DB error: Unable to resolve FQDN (0.090774s)
CodePudding user response:
TDengine connecting is based on FQDN(hostname if it familiar to you) - which requires DNS resolution for the server end point).
In your case, first set the hostname in start: docker run --hostname taosd ...
, and then echo <your ip> taosd >> /etc/hosts
in your shell located container or host. then you can connect it with taos -h taosd
(here we use taosd as the TDengine server container hostname, all the connections should use hostname to resolve the real ip.)
Steps:
start TDengine server:
docker run --rm --hostname taosd \ -p 6030-6042:6030-6042/tcp -p 6030-6040:6030-6040/udp \ --name taosd tdengine/tdengine
start another container as client:
docker run --rm -it --add-host taosd:<your ip> tdengine/tdengine taos -h taosd
--add-host
will add an dns resolvation line in /etc/hosts.<your ip>
you could use the external IP or get the container ip bydocker inspect taosd |jq '.[0].NetworkSettings.Networks[].IPAddress' -r
.now insert data with your sql:
create database if not exists test; use test; create table if not exists tb1 (ts timestamp, n int); insert into tb1 values (now, 1);
All done.