for name in openldap cfengine-selenium-tests; do
  # TODO: a softer clean might get into the container and run ./buildscripts/build-scripts/clean-buildmachine
  if docker ps | grep $name; then
    docker stop $name
  fi
  if docker ps -a | grep $name; then
    docker rm $name
  fi
  # probably we dont want to remove the image all that often, but maybe if we want to invalidate the docker layers cache:
  #docker rmi $name
done

# tear down the network we create in docker.sh
if docker network ls | grep cfengine-selenium-tests; then
  docker network disconnect cfengine-selenium-tests openldap
  docker network disconnect cfengine-selenium-tests cfengine-selenium-tests
  docker network rm cfengine-selenium-tests
fi
