Skip to content

Commit

Permalink
More info on resource constraints in Compose v3 and v2 (docker#4651)
Browse files Browse the repository at this point in the history
* added more info about resource constraints to Compose docs

Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>

* fixed link in Compose docs, added instructions in test for adding custom target link link IDs

Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>

* fixed links

Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>
  • Loading branch information
londoncalling authored Sep 18, 2017
1 parent 4641ccf commit 02fc66f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 2 additions & 0 deletions compose/compose-file/compose-file-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,8 @@ then read-write will be used.
- restart: always
- restart: on-failure

{: id="cpu-and-other-resources"}

### cpu_count, cpu_percent, cpu\_shares, cpu\_quota, cpus, cpuset, domainname, hostname, ipc, mac\_address, mem\_limit, memswap\_limit, mem\_swappiness, mem\_reservation, oom_score_adj, privileged, read\_only, shm\_size, stdin\_open, tty, user, working\_dir

Each of these is a single value, analogous to its
Expand Down
24 changes: 21 additions & 3 deletions compose/compose-file/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ services:
delay: 10s
restart_policy:
condition: on-failure

db:
image: postgres:9.4
volumes:
Expand Down Expand Up @@ -650,8 +650,12 @@ Configures resource constraints. This replaces the older resource constraint
options in Compose files prior to version 3 (`cpu_shares`, `cpu_quota`,
`cpuset`, `mem_limit`, `memswap_limit`, `mem_swappiness`).

Each of these is a single value, analogous to its
[docker service create](/engine/reference/commandline/service_create.md) counterpart.
Each of these is a single value, analogous to its [docker service
create](/engine/reference/commandline/service_create.md) counterpart.

In this general example, the `redis` service is constrained to use no more than
50M of memory and `0.001` (0.1%) of available processing time (CPU), and has
`20M` of memory and `0.0001` CPU time reserved (as always available to it).

```none
version: '3'
Expand All @@ -668,6 +672,20 @@ services:
memory: 20M
```

The topics below describe available options to set resource constraints on
services or containers in a swarm.

> Looking for options to set resources on non swarm mode containers?
>
> The options described here are specific to the
`deploy` key and swarm mode. If you want to set resource constraints
on non swarm deployments, use
[Compose file format version 2 CPU, memory, and other resource
options](compose-file-v2.md#cpu-and-other-resources).
If you have further questions, please refer to the discussion on the GitHub
issue [docker/compose/4513](https://github.com/docker/compose/issues/4513){: target="_blank" class="_"}.
{: .important}

##### Out Of Memory Exceptions (OOME)

If your services or containers attempt to use more memory than the system has
Expand Down
14 changes: 14 additions & 0 deletions test.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ https://github.com/docker/docker.github.io/tree/master/docker-cloud/images
- [a markdown link that opens in a new window](https://docker.com/){: target="_blank" class="_" }
(the `class="_"` trick prevents Atom from italicizing the whole rest of the file until it encounters another underscore.)

- [a markdown link to a custom target ID](#custom-target-id)

- <a href="https://docker.com/">an HTML link</a>

- <a href="https://docker.com/" target="_blank" class="_">an HTML link that opens in a new window</a>
Expand All @@ -85,6 +87,18 @@ https://github.com/docker/docker.github.io/tree/master/docker-cloud/images

(you can also specify `org=foo` to use a Github organization other than Docker).

{: id="custom-target-id"}

#### Using a custom target ID
This topic has a custom target ID above its heading that can be used to link to
it, in addtion to, or instead of, the default concatenated heading style.

You can use custom targets to link to headings or even paragraphs.

An example of a custom target ID in the documentation is the topic on
[Compose file version 2 topic on CPU and other resources](/compose/compose-file/compose-file-v2.md#cpu-and-other-resources).
It has a long heading that breaks the normal markdown linking mechanism,
so we added a custom ID above the target heading.

### Images

Expand Down

0 comments on commit 02fc66f

Please sign in to comment.