Closed ItsKarma closed 3 years ago
I am running pytest inside a docker container. I was originally running my tests against the live mongo container. This live container was a part of a different docker "network" so my pytest container did not have direct access via the docker network. To get around this I was adding --network="host"
to my pytest container'sdocker run
command. I believe this caused pymongo_inmemory to not see that my host was using port: 27017, because within the pytest container where pymongo_inmemory was running, there was no port 27017. However, when attempting to connect to port 27017, because of the --network=host
flag, it was actually connecting to the host port 27017 which was the live mongo container.
To resolve this, I removed the --network=host
flag, as I no longer need to reach out to the live mongo container when using pymongo_inmemory.
Thanks for the great project!
Hi Matt,
Thanks for using pymongo_inmemory
!
Even though you have closed your issue, I'll have a look and see if we can provide a better solution.
Best,
Ertugrul
Describe the bug If running a live mongodb instance at localhost:27017, pymongo_inmemory attempts to connects to it and fails operations.
To Reproduce Steps to reproduce the behavior:
docker run -itd -p 27017:27017 -v db-data:/data/db mongo:4
docker run -itd -p 27018:27017 -v db-data:/data/db mongo:4
Expected behavior I would expect pytest to connect to pymongo_inmemory instead of the running mongo docker container. I suspect the port checking that pymongo_inmemory does, is incompatible with Docker, or is simply not working. I have not tested this running mongo locally outside of a docker container, but that is not applicable to my use case.
This does not block me from using pymongo_inmemory, but is inconvenient. I either need to run mongo on a non-default port, or I have to shut down the running container which I use for active development, prior to running tests.
Logs I don't think there are any logs to provide.
Screenshots N/A
Context: