Aspire in windows Not connecting to Docker Desktop on Mac M1

Ali AL Hoshaimy 0 Reputation points
2025-09-13T02:25:07.4833333+00:00

I have docker desktop running on Mac M1, and trying to connect to it from Visual Studio in Windows 11 inside Parallels. I am able to browse apps running in Docker from edge in windows with no issues.
Aspire app out project is able to run the docker containers, however, it is connecting to them using the localhost connection string. I want to force Aspire to use "host" instead of "localhost".
any idea?

Developer technologies | Visual Studio | Debugging
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Susmitha T (INFOSYS LIMITED) 755 Reputation points Microsoft External Staff
    2025-09-16T09:08:55.13+00:00

    Hope you are doing good! Thank you for reaching out. Please find the answer below.

     

    1.Check Environment Variables: You can try setting the ASPIRE_HOST environment variable in your Windows environment to the appropriate host IP address. Sometimes, using host.docker.internal can help bridge the network between Docker containers and the host machine.

     

    2.Modify Connection String: If you can, modify the connection string in your Aspire app configuration to point to the host address. Here's a possible format:

     

    {  
    "ConnectionStrings": {
        "DefaultConnection": "Server=host;Database=yourDatabase;User Id=yourUser;Password=yourPassword;"
      }
    }

     

    3.Inspect Docker Settings: Ensure Docker is set up properly in Parallels. Sometimes, adjusting the network settings might help establish a better connection.

     

    4.Firewall/Network Policies: Ensure there are no firewall rules on your Windows system or network policies in your Docker settings that could be blocking the connection.

     

    5.Ensure Docker on the Mac is configured to expose the daemon over TCP:

     

    Open Docker Desktop → Settings → General → Enable “Expose daemon on tcp://localhost:2375 without TLS”.

     

    6.Restart Aspire or Visual Studio after setting the environment variable.

     

    If the issue still persists, we'll happy to assist further needed.  "Kindly mark the response as answered if the issue resolved".


  2. Susmitha T (INFOSYS LIMITED) 755 Reputation points Microsoft External Staff
    2025-09-17T11:01:45.61+00:00

     Hope you are doing good! Thank you for reaching out. Please find the answer below.

    Aspire is still defaulting to localhost. Here's how to force it to use the correct host:

    1. Verify Aspire Configuration

    Ensure Aspire is actually reading the ASPIRE_HOST environment variable. You might need to:

    • Set it in the Visual Studio launch settings (launchSettings.json).
    • Or set it globally in Windows Environment Variables and restart Visual Studio.
    1. Update Connection Strings Explicitly

    In your Aspire app’s configuration (e.g., appsettings.json or Program.cs), replace localhost with 10.211.55.2 or host.docker.internal:

     

    "ConnectionStrings": {

      "DefaultConnection": "Server=10.211.55.2;Database=yourDatabase;User Id=yourUser;Password=yourPassword;"

    }

     

    1. Use host.docker.internal

    This alias works well across Docker Desktop setups and is often more reliable than raw IPs.

     

    1. Check Docker Health Probes

    The "unhealthy" status might be due to missing or misconfigured health checks in your Dockerfiles or Compose setup. Add proper HEALTHCHECK instructions if needed.

     

    1. Expose Docker Daemon Properly

    Make sure Docker Desktop on Mac has:

    • “Expose daemon on tcp://localhost:2375 without TLS” enabled.
    •  Firewall rules allow traffic from Parallels VM to port 2375.

    Let me know if you need any further help with this. We'll be happy to assist.

              If you find this helpful, please mark this as answered. 


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.