Docker Community Forums

Share and learn in the Docker community.

Using sudo will increase container creation time

We are scaling to thousands of docker containers on a single host. We have noticed an increased execution time when executing 'sudo docker run…" command, compared to running as a root user (or adding to the docker group).

The execution time of sudo commands increase as the number of containers increases. This means that if you are creating lets say 6,000 containers per host, the last container created with sudo will take much more time to create than the first container. This is because we are creating containers with sudo.

sudo iterates over every network interface on the host. As we scale up the number of docker containers on the host (adding veth devices), the execution time of any sudo command will increase (more network interfaces to iterate over).

Here is some data from running ‘docker run’ command in a loop with a docker version 1.12.1. The time represents the total time it takes to create 4000 containers:

sudo docker run…: 30:23.34
(as root user) docker run…: 14:31.97

Recommend running docker commands as a root user or adding docker group. Does anyone else have similar observations?