To export a container:
docker export --output="container.tar" <container-name>
This will export your container to container.tar which can be imported back on another machine using:
docker import container.tar <container-name>.
However, as stated in the docker export docs:
The docker export command does not export the contents of volumes
associated with the container. If a volume is mounted on top of an
existing directory in the container, docker export will export the
contents of the underlying directory, not the contents of the volume.
Now mongo exposes /data/db
and /data/configdb
as volumes. Thus they will not be exported with the tar ball. Thus the data and config won't be in the tar :(
VOLUME /data/db /data/configdb
What you need to do in order to get this data is either one of the follow:
How to port data-only volumes from one host to another?
Copy these folders form inside the container manually and copy them back to the new container when your import it from the tar.
docker cp :/data/db ./data
docker cp :/data/configdb ./config
Copy these folder to the new host, then import the tarred container and finally copy back these folder into the container
docker cp data/* <new-container>:/data/db
docker cp config/* <new-container>:/data/configdb