Docker Community Forums

Share and learn in the Docker community.

Library to programmatically test docker setups

I am currently developing a system, whichs infrastructure runs in docker. Is there a library which allows to test if the running docker containers and their config are correct?

For example I have a CLI, which allows to update the config of a docker service. I would like to have some library, (preferably in java) which makes this service config update via the CLI automagically testable. This includes

  1. Create the infrastructure from scratch (preferably inside of a single container using docker in docker)
  2. Check the initial state of the config
  3. Update the config using the CLI (this is not the problem)
  4. Check if the config is updated and let the test fail if that’s not the case.

I have already seen but they just make you able to run single JUnit tests inside of containers and not test a whole infrastructure.

Do you know a good way of doing this or am I forced to develop a custom system using GitHub - docker-java/docker-java: Java Docker API Client?

You need a Dockerfile for each custom image you want to build; you also need a Dockerfile for each container to be deployed, whether you deploy automatically from Visual Studio or manually using the Docker CLI (docker run and docker-compose commands). If your application contains a single custom service, you need a single Dockerfile. If your application contains multiple services (as in a microservices architecture), you need one Dockerfile for each service.

The Dockerfile is placed in the root folder of your application or service. It contains the commands that tell Docker how to set up and run your application or service in a container. You can manually create a Dockerfile in code and add it to your project along with your .NET dependencies.