This chapter covers
- Reviewing how to start and stop Docker containers via the commandline
- Introducing the Docker API calls for starting and stopping containers
- Implementing the Task concept to start and stop a container
Think about cooking your favorite meal. Let’s say you like making homemade pizza. In order to end up pulling a delicious, hot pizza out of your oven, you have to perform a number of tasks. If you like onions, green peppers, or any other veggies on your pizza, you have to cut them up. You have to knead the dough into a baking sheet. Next, you spread tomato sauce across the dough and sprinkle cheese over it. Finally, on top of the cheese, you layer your veggies and other ingredients.
A task in an orchestration system is similar to one of the individual steps in making a pizza. Like most companies these days, yours most likely has a website. That company’s website runs on a web server, perhaps the ubiquitous Apache web server. That’s a task. The website may use a database, like MySQL or PostgreSQL, to store dynamic content. That’s a task.
In our pizza making analogy above, the pizza wasn’t made in a vacuum. It was created in a specific context, which is a kitchen. The kitchen provides the necessary resources to make the pizza: there is a refrigerator where the cheese is stored; cabinets where the pizza sauce is kept; an oven in which to cook the pizza; knives to cut the pizza into slices.