Reputation: 321
I am looking into how to use mongoimport
on my container running a python program to send a file on that python container over to another container on the same docker network.Currently I am using the following command to try to do this:
mongoimport --host mongo --port 27017 --db vulns --collection qualys-kb --file kb.json --jsonArray
In the above command, I am trying to connect to the container called mongo
, which is on the same docker network as the container that is running this command. mongo
is currently running mongodb and is accessible through the standard 27017 port. Yet when I try to run the above command I get the following error:
2023-09-21T12:39:09.184+0000 error connecting to host: failed to connect to mongodb://mongo:27017/: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: mongo:27017, Type: Unknown, Last error: connection() error occurred during connection handshake: dial tcp: lookup mongo on 192.168.1.1:53: no such host }, ] }
Can anyone offer any advice on how to get this working so that I can reference the mongo container by name in the mongoimport
command. If there is a different approach to do the same thing I would be open to that too.
Upvotes: 0
Views: 65