Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a maximum number of containers running on a Docker host?

Tags:

docker

Basically, the title says it all: Is there any limit in the number of containers running at the same time on a single Docker host?

like image 863
Golo Roden Avatar asked Feb 15 '14 15:02

Golo Roden


People also ask

How many containers can a Docker host?

Runs Eight Containers per Host.

What is maximum number of containers you can run per host?

Using this simple calculation, we can estimate that we can run about 1,000 containers on a single host with 10GB of available disk space.

Can we run multiple Docker containers on a single host?

You can run both containers using different host ports, and use a haproxy/nginx/varnish (native or inside another container) listening to the host port, and redirecting to the right container based on the URL. Show activity on this post. This is as much a question about the way tcp ports work as the way docker works.

Is there any limitations for the number of containers that we can have?

The overall limits will normally be decided by what you run inside the containers rather than dockers overhead (unless you are doing something esoteric, like testing how many containers you can run :) If you are running apps in a virtual machine (node,ruby,python,java) memory usage is likely to become your main issue.


2 Answers

There are a number of system limits you can run into (and work around) but there's a significant amount of grey area depending on

  1. How you are configuring your docker containers.
  2. What you are running in your containers.
  3. What kernel, distribution and docker version you are on.

The figures below are from the boot2docker 1.11.1 vm image which is based on Tiny Core Linux 7. The kernel is 4.4.8

Docker

Docker creates or uses a number of resources to run a container, on top of what you run inside the container.

  • Attaches a virtual ethernet adaptor to the docker0 bridge (1023 max per bridge)
  • Mounts an AUFS and shm file system (1048576 mounts max per fs type)
  • Create's an AUFS layer on top of the image (127 layers max)
  • Forks 1 extra docker-containerd-shim management process (~3MB per container on avg and sysctl kernel.pid_max)
  • Docker API/daemon internal data to manage container. (~400k per container)
  • Creates kernel cgroups and name spaces
  • Opens file descriptors (~15 + 1 per running container at startup. ulimit -n and sysctl fs.file-max )

Docker options

  • Port mapping -p will run a extra process per port number on the host (~4.5MB per port on avg pre 1.12, ~300k per port > 1.12 and also sysctl kernel.pid_max)
  • --net=none and --net=host would remove the networking overheads.

Container services

The overall limits will normally be decided by what you run inside the containers rather than dockers overhead (unless you are doing something esoteric, like testing how many containers you can run :)

If you are running apps in a virtual machine (node,ruby,python,java) memory usage is likely to become your main issue.

IO across a 1000 processes would cause a lot of IO contention.

1000 processes trying to run at the same time would cause a lot of context switching (see vm apps above for garbage collection)

If you create network connections from a 1000 containers the hosts network layer will get a workout.

It's not much different to tuning a linux host to run a 1000 processes, just some additional Docker overheads to include.

Example

1023 Docker busybox images running nc -l -p 80 -e echo host uses up about 1GB of kernel memory and 3.5GB of system memory.

1023 plain nc -l -p 80 -e echo host processes running on a host uses about 75MB of kernel memory and 125MB of system memory

Starting 1023 containers serially took ~8 minutes.

Killing 1023 containers serially took ~6 minutes

like image 120
Matt Avatar answered Sep 22 '22 06:09

Matt


From a post on the mailing list, at about 1000 containers you start running into Linux networking issues.

The reason is:

This is the kernel, specifically net/bridge/br_private.h BR_PORT_BITS cannot be extended because of spanning tree requirements.

like image 33
darron Avatar answered Sep 20 '22 06:09

darron