The software described in this documentation is either no longer supported or is in extended support.
Oracle recommends that you upgrade to a current supported release.

4.17 Building Images with Resource Constraints

From version 1.6.0 of Docker, you can specify cgroup resource constraints to docker build, for example:

# docker build --cpu-shares=100 --memory=1024m \
   --tag="mymod/myapp:1.0" /var/docker_projects/mymod/myapp/

Any containers that you generate from the image inherit these resource constraints.

You can use the docker stats command to display a container's resource usage, for example:

# docker stats cntr1 cntr2
CONTAINER     CPU %      MEM USAGE/LIMIT     MEM %     NET I/O
cntr1         0.05%      504 KiB/128 MiB     0.39%     2.033 KiB/40 B
cntr2         0.08%      1.756 MiB/128 MiB   1.37%     5.002 KiB/92 B