Container Resources and Docker Compose
Orchestrators such as Kubernetes and Swarm go a long way in controlling and running your resources and spinning up new hosts if there are extra resources needed. But what do you do if you are running docker-compose
in your system or a test environment? Fortunately, the previously mentioned resource configurations work nicely with docker-compose
as well.
Within our docker-compose.yml
file, under our service, we can use the resources
option under the deploy
configurations and specify our resource limits for our service. Just as we have been using options such as --cpus
, --cpu_shares
, and --memory
, we would use the same options in our docker-compose.yml
file as cpus
, cpu_shares
, and memory
.
The example compose
file in the following code block is deploying the docker-stress
image we have been using in this chapter. If we look at line 8, we can see the deploy
statement, followed by the resources
statement. This is where we can set our limits...