Docker build and test built image


We are currently using codeship but frustrated with how slow it is. Trying out circleci. What we do in codeship is build our docker image, then test a container running that image, then if the tests pass we publish that image to aws ecr. I’ve been looking over the documentation for circleci 2.0 and building docker images here:, but this does not follow the process I outlined. Instead it assumes we load the contents of our image into circleci build environment/public dockerhub docker image (this seems flawed as it would require us to match the circleci config.yml contents to our Dockerfile contents which is not DRY and prone to errors), do the testing, and then do a docker build at the end. I’d much rather test the image that I built from our Dockerfile so that I know what I am putting into production is what I tested. Can you point me at an example of doing that? There’s a lot of discussion here that that cannot be done because the image I build and run inside the circleci build docker container will not be able to communicate with the postgresdb, redis, and other dependencies which are running in other containers. It seems the logical thing would be to allow me to build the top level docker image and use that as the test container vs pulling a public one from dockerhub? Is that possible?