-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance of start/stop/remove container #215
Comments
Hi @forfcw and thanks for reporting this issue. I've done a simple test to try to replicate what you see. In my case, I have a really weak hp dragonfly laptop with an "Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz, 1992 Mhz, 4 Core(s)" with probably not the fastest ram in the world ;) I'm using WSL2. Using the following sample (I will check it in this into Examples Solution later on) Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var hosts = new Hosts().Discover();
var host = hosts.FirstOrDefault(x => x.IsNative) ?? hosts.FirstOrDefault(x => x.Name == "default");
Console.WriteLine("Hosts discovered in {0} s", TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds);
var _container = host.Create("nginx:alpine",
prms: new ContainerCreateParams
{
Name = "test",
Network = "host",
PortMappings = new string[] { "9111:80", "9112:443" },
Volumes = new string[] { "/data/log:/var/log:rw" },
RestartPolicy = RestartPolicy.Always
});
Console.WriteLine("Create container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds);
try
{
stopwatch.Restart();
_container.Start();
Console.WriteLine("Start container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds);
} finally
{
stopwatch.Restart();
_container.Dispose();
Console.WriteLine("Dispose container: " + TimeSpan.FromMilliseconds(stopwatch.ElapsedMilliseconds).TotalSeconds);
stopwatch.Stop();
} It will output the following:
When I try to do it on my shell, the creation will take around one to two seconds so I think FluentDocker, in this case, do not add any substantial additional time. I will investigate this a bit further, but in the meantime can you please use the docker commands from the shell and clock how long an "nginx:alpine" takes to start and be deleted on your system? 💡 Note that it will call both stop and remove when disposing the container. docker -H unix:///var/run/docker.sock start 37ec8c07e093b452b3a18346b4338dd7bdb33d203582b1bd8d0035f888f2921a
docker -H unix:///var/run/docker.sock inspect 37ec8c07e093b452b3a18346b4338dd7bdb33d203582b1bd8d0035f888f2921a
docker -H unix:///var/run/docker.sock stop 37ec8c07e093b452b3a18346b4338dd7bdb33d203582b1bd8d0035f888f2921a
docker -H unix:///var/run/docker.sock rm --force 37ec8c07e093b452b3a18346b4338dd7bdb33d203582b1bd8d0035f888f2921a Cheers, |
May be I wronged FULENTDOCKER, It takes the same time in shell! |
Have you got some performance problems with start/stop/remove containers?
It usually takes 4s or more to start a container, sometimes finding and deleting a container even takes 6s.
Looking forward to your recovery!
The text was updated successfully, but these errors were encountered: