Is there a way to schedule docker containers to run with respect to one another?

4/5/2019

I'm creating microservices using Docker Containers.

Initially, I run one Docker container and it provides me with some output that I need as input for a second docker container.

So the flow of steps would be:

  1. Run Docker container;
  2. Get output;
  3. Trigger running of second Docker container with previous output.

I have looked into Kubernetes, cloud functions and pub/sub on Google Cloud. Though I would like to run this locally first.

Unfortunately, I haven't found a solution, my processes are more like scripts than web-based applications.

-- DuDoff
bash
docker
kubernetes
python

2 Answers

4/5/2019

If you are asking from a auto-devops point of view, you can try utilizing kubectl wait command for this.

  • Prepare yaml files for each of the containers (eg pod, deployment or statefulset)
  • Write a shell script, running kubectl apply -f on the files.
  • Use kubectl wait and jsonpath to pass info from prvious pods to the next, once it's in the ready / RUNNING state.

Find the detailed docs here.

-- cookiedough
Source: StackOverflow

4/5/2019

You can have a look at Kubernetes Jobs. It might do the trick, although Kubernetes was not really made for running scripts in sequence and sharing dependencies between containers.
This thread is similar to what you need. One tool mentioned that intrigued me was brigade.

-- victortv
Source: StackOverflow