Reputation: 37
I have started working with Docker and so far, everything works. Until now, I have created a docker file which creates a container and inside this, runs a dotnet application.
Now, the question comes to me if accomplishing the following task is possible:
I have e.g. 5 Json-Files. One docker container relies on one Json-file due to the dotnet application (the json-file includes credentials which are needed by the dotnet application). So, is there a possibility that it is checked how many json-files are locally stored in the path xy, and, depending on the amount, automatically 5 containers are started and, afterwards, one json-file is passed to each of them?
I did not find anything and I don't know what the best approach is for such a scenario. A script would be great, maybe Linux or powershell? I don't think that this task can be realised by a simple docker file - but maybe I am wrong.
Thanks to everyone for any tips. :-)
Upvotes: 2
Views: 130
Reputation: 664
What you need is a container orchestrator.
The simplest solution would be to write a shell script and spawn container with the JSON file name as an argument. You can also select the JSON file to use through the script and only copy this file to the container.
Eventually, consider running these containers through Kubernetes/docker swarm. For Kubernetes, use https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/. We can define templates here. Each JSON file can be named in sequence, and the parameter can be templated.
Eg: config-1.json config-2.json
Upvotes: 1