Creating containers dynamically


I am planning to create an application to benchmark OSINT tools.
To do so, I want to create a web interface where we can choose which tool to benchmark.
So I createe templates for each tool where we can edit the command to execute and the targets

For example I’ll create a template for dnsenumeration like this:
command: command
arguments: -d

From the input of the user on the web interface, it will create one docker container per tool and execute the commands then return the result to the web interface (which is also a container)

Do you know how I can handle the dynamic generation of containers like that ? Create as many as I want then delete them as soon as they’re finished with their tasks. They need to be as lightweight as possible.

Thank you your answers ! :slight_smile:

So if I understand it correctly, you need something like Portainer, except that you have a specific goal and want to program that. You still need an SDK in any language you understand.

The rest is programming


Thanks for your quick answer. :slight_smile:
At first I didn’t quite understand your answer since I am not really familiar with docker.
If I understand it correctly :

  • Portainer will act as the web interface which will receive the tools’ results (sent by the dynamically deployed containers)
  • I didn’t know there’s was an SDK to interact with the docker daemon. I looked it up and I can run a container based on image this way :
image, _ ='.', dockerfile=f"Dockerfile.{tool}", tag=tool)

    container =,
        environment={"DOMAIN": domain},
        volumes={os.path.abspath("results"): {'bind': '/results', 'mode': 'rw'}},

Which is quite convenient and is perfect for my project since I just need to run as many containers as needed.

Maybe Portainer isn’t necessary since I just need one container to deploy one container to receive all the data (web server) and the others are run to do the different commands and return the results.

To give you the bigger picture, this is the lifecycle of my application:

  • User starts the application
  • User selects on the web interface (for example flask in a docker container) the tests to run and validate his choices.
  • Application starts one docker container per tool to perform the tests.
  • Each tool’s container git clone the tool it was in charge of.
  • Each tool’s container run the commands based on pre-designed templates (YAML templates for example)
  • Each tool’s container send the results to the web interface at a special endpoint (let’s say POST request to /results of the API)
  • Each tool’s container is deleted.
  • Web Interface shows the results and exports them
  • User stops the application

I hope that was clear.

Thanks again for your help.

Portainer is a Web based UI for browsing and managing containers. You can even choose an app from the the templates and install it. It is good to learn and debug, but I would not use it for creating containers in production. I just shared it as an example as it has to communicate with the API too.