3

I've read about the limitations on Docker containers, and also on the maximum number of container running, but I'd like to do the following:

  • Start a container on-the-fly (milliseconds).

In order to do so, I've noticed that I have to create it beforehand; this will save me about 2 seconds each time. This made me wonder:

  • Is there any limitation to the number of created containers? Do they use any resources?
    • obviously it uses disk space to store it
    • does it also preload it in RAM, or not?
      • related: is the "active" state of the process saved on stopping, or is it the process stopped, and started on start? (if the latter is the case, then why would anyone bother to re-create containers? )
    • does it have a reserved IP address? And if so, is there a maximum number of private IP addresses Docker will use?
    • ... anything else that might prevent me from having 50,000 containers?
Community
  • 1
  • 1
Etienne Bruines
  • 2,848
  • 3
  • 17
  • 25
  • 2 seconds? Are you using a boot2docker-like type of environment, with a Linux VM? – VonC Oct 22 '15 at 05:47
  • Using the Remote API to issue the create command (image is about 14MB), running locally (Linux 64bit; 8 cores @ 3.4GHz, but only a HDD - no SSD). – Etienne Bruines Oct 22 '15 at 05:59
  • I meant are you on Linux directly, or using docker through a Linux VM? – VonC Oct 22 '15 at 05:59
  • Ok, I did experience long docker run time (but I do quite a lot in my run scripts though, as in https://github.com/VonC/b2d/blob/1a3a147bb59a209f1cedd0c37c4a2cddef3d6ea5/gitolite/run#L33) – VonC Oct 22 '15 at 06:01
  • Thank you for letting me know (I appreciate it). I apologize for asking, but, how does this help? – Etienne Bruines Oct 22 '15 at 06:09
  • I was just curious to see if your execution environment might explain the high startup time. As for your questions, I am still reading https://docs.docker.com/articles/networking/ – VonC Oct 22 '15 at 06:10
  • Well, the fact that you were experiencing faster builds than I, was kind of interesting (and helped). Using RAMFS instead of a regular HDD, boosted the build time from 2400ms to 400ms. – Etienne Bruines Oct 22 '15 at 06:58

1 Answers1

1

If a container is only created, there is no running process (and nothing is [pre-]cached either). I've also verified that if the container isn't running yet, the NetworkSettings section of docker inspect is blank, so no IP addresses should be allocated in this case. The metadata stored on disk to track the "container object" should be the only impact (and whatever memory the Docker daemon uses at runtime while keeping track of said metadata, which likely includes a copy of the metadata itself).

I've run for i in {0..999}; do docker create --name hello-$i hello-world; done on my local machine to test this, and it completed successfully (although took what seems like an embarrassingly long time to complete, given that it's looking up and writing out the exact same metadata repeatedly).

tianon
  • 1,866
  • 3
  • 22
  • 37