Sql import by generic sql dump in insecure mode

I have cdb running in a aws instance inside docker in insecure mode. i created a dump file there for two tables with schema and data both.
I installed docker and cdb inside my system then(in insecure mode only) and transferred that sql dump file from the aws instance to my system.
Then when I tried to import the dump file in my system’s cdb by following commands with respective behaviour:

docker exec admin_cockroachdb_1 ./cockroach sql --insecure --database=nakama < /path/to/data.sql
But nothing happened in the terminal and the terminal got hanged and I couldn’t enter any line on that terminal after that. In another terminal window I looked at the db , and the data didn’t import as well.
Then I tried:

docker exec admin_cockroachdb_1 ./cockroach sql --database=nakama < /path/to/data.sql
but this time I got the following error:
Error: problem using security settings, did you mean to use --insecure?: problem with CA certificate: not found
Failed running “sql”

How Can I import this data in the data.sql file into my cdb running inside docker in insecure mode?

It looks like that second error is expected: the cockroach command assumes you’re trying to connect to a secure node unless the --insecure field is specified.

I suspect the problem is that cockroach is not able to access the file from within the docker container. Docker’s solution for this is to either mount the file or create a volume within the container. You can see us adding a volume for cockroach data in step 2 of our Docker instructions.

Hope that helps! Let me know if you have any further questions.

The docker documentation isn’t very clear on this, but it appears that stdin only works for docker exec if you pass the -i flag. Try docker exec -i admin_cockroachdb_1 ./cockroach sql --insecure --database=nakama < path/to/data.sql

Thank you @tim-o and @bdarnell for your replies.
By using -i flag I was able to debug the execution of the dump file.

For anyone who is trying to do the same here is the solution:

when one create a dump file with cockroachdb or mysql, several other data is also present in the dump file (in my case the dump created from cockroachdb had two statements starting with # at the top, and the dump created from mysql in addition to the additional lines the these, also had the name of the table under single quotes 'table_name' , which needed to be removed ),and one has to remove all these lines and make sure that only insert statements with table names without any single quotes are present.
then run the command mentioned by @bdarnell and it runs fine.

Just a follow up question
I have another linux instance in which cockroach is installed in binary and in insecure mode only.
(For some reason I don’t have access to the instance for the next few days but once I do )
cockroach sql --insecure --database=nakama < path/to/data.sql

will solve my purpose, right?

Yes, that will work as long as you’re running an insecure server on the same machine (if it’s running somewhere else you’ll need to pass a --host flag too)

Thank you @bdarnell, got the point. :smile: