SMO, SSMS are slow for management of SQL Server in Docker when connecting to localhost

This is most likely a RAM starvation issue.

Things to check:

  • Does the container have 4 GB of RAM assigned to it? Check this answer.
  • Have you configured the Max Server Memory setting for SQL Server inside the container? Depending on how much RAM SQL Server can see in the container, this might be set to anything from 1 GB to 3.25 GB.
  • Is your host's RAM used up, and is it possible that Docker is paging to disk? Close any extraneous applications (web browsers are big consumers of RAM). SSMS needs around 1 GB of working RAM to be useable.
  • Is this faster after a reboot?

If I were doing this myself, I'd install the Docker Community Edition for Windows from the Docker store, and then install the SQL Server Docker image that way.

If your Internet connection is fast enough, you can be up and running in under 5 minutes, and be able to allocate resources in a much easier way.

EDIT: Ah, networking.


The key difference here is whether SSMS/SMO is attempting to connect with IPv4 or IPv6. If you do a ping localhost in a command prompt, you should see it resolve to ::1, which is the IPv6 equivalent of 127.0.0.1. Connecting to . does the same thing.

Your docker run command only exposes port 1433 on 127.0.0.1. You can verify this by running netstat -a to see which ports are available.

The hosts file alias you created resolves directly to 127.0.0.1, but you don't need it, since you can connect to 127.0.0.1 directly in SSMS and solve your problem that way. Turning off IPv6 entirely on your host system would probably also work, but I'm not sure how advisable this is on Windows 10.

I'll consider an alternate answer to accept if anyone can tell me why IPv6 is causing this to break.