I want to Execute mongoimport on a Docker Container

With your description it seems that you have a datafile in json format in your host machine and you want to import this data into mongodb which is running in a container.

You can follow following steps to do so.

#>docker exec -it <container-name> mongo
#>docker cp xxx.json <container-name-or-id>:/tmp/xxx.json
#>docker exec <container-name-or-id> mongoimport -d <db-name> -c <c-name> --file /tmp/xxx.json

In the last step you have to use file path that is available in the container.

To debug more if required you can login into the container and execute the way you do on the Linux machines.

#>docker exec -it <container-name-or-id> sh
sh $>cat /tmp/xxx.json
sh $>mongoimport -d <db-name> -c <c-name> --file /tmp/xxx.json

Run without copy file:

docker exec -i <container-name-or-id> sh -c 'mongoimport -c <c-name> -d <db-name> --drop' < xxx.json