testcontainers-rs icon indicating copy to clipboard operation
testcontainers-rs copied to clipboard

Ability to run tests inside a docker container themselves

Open wngr opened this issue 6 years ago • 3 comments

Hey,

the current approach of this library assumes that cargo test is executed on the host system running docker. For having a reproducible environment, it makes sense to run the tests themselves inside a docker container. To be able to have those tests spin up and access other containers, we'd need to:

  1. Be able to access the docker socket from within the container (and have docker-cli installed)
  2. Make sure the networking is properly set up, e.g. same docker network / bridging
  3. Ability to get the IP of the created container --> docker inspect has it

My proposed approach would be to create another Client and implement 2 and 3 as enumerated above. Obviously, to be able to use it, the library users needs to make sure 1 is properly set up.

What do you think about this approach? Would you be willing to accept a PR implementing the above?

wngr avatar Oct 23 '19 11:10 wngr

Maybe look into the shiplift crate so you don't create a docker api client from scratch.

D4nte avatar Oct 23 '19 23:10 D4nte

What do you think about this approach? Would you be willing to accept a PR implementing the above?

Yes definitely! That is the direction we would want to take this library in, we just didn't have any needs for it so far :) We would definitely accept a PR for this!

thomaseizinger avatar Oct 24 '19 00:10 thomaseizinger

Maybe look into the shiplift crate so you don't create a docker api client from scratch.

Thanks for the hint, will give it a spin then!

wngr avatar Oct 24 '19 05:10 wngr