title: Docker Cannot assign requested address on .NET app with Selenium
body: <p>I'm trying to make a Web Scraper as a .NET project and I'm required to run the app on a Docker container using Linux on WSL2. The problem is that this app uses Selenium Webdriver and every time i try to run the app on Visual Studio 2022 i get the following error</p>
  <pre><code>Cannot assign requested address [::1]:39307 (localhost:39307)
  ./chromedriver: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory
  </code></pre>
  <p>My dockerfile is the following</p>
  <pre><code>#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
  
  FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
  WORKDIR /app
  
  FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
  WORKDIR /src
  COPY [&quot;ConsoleApp1/ConsoleApp1.csproj&quot;, &quot;ConsoleApp1/&quot;]
  RUN dotnet restore &quot;ConsoleApp1/ConsoleApp1.csproj&quot;
  COPY . .
  WORKDIR &quot;/src/ConsoleApp1&quot;
  RUN sudo apt-get install -y libgbm-dev
  RUN apt-get update &amp;&amp; apt-get install -y  google-chrome-stable
  RUN dotnet build &quot;ConsoleApp1.csproj&quot; -c Release -o /app/build
  
  FROM build AS publish
  RUN dotnet publish &quot;ConsoleApp1.csproj&quot; -c Release -o /app/publish
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app/publish .
  ENTRYPOINT [&quot;dotnet&quot;, &quot;ConsoleApp1.dll&quot;]
  </code></pre>
  <p>And the code that produces the error is this one</p>
  <pre><code>using OpenQA.Selenium.Chrome;
  
  namespace IntroSelenium
  {
      class Program
      {
          static void Main(string[] args)
          {
              var chromeOptions = new ChromeOptions();
              chromeOptions.AddArguments(&quot;headless&quot;);
              chromeOptions.AddArguments(&quot;--verbose&quot;);
              using (ChromeDriver driver = new ChromeDriver(&quot;.&quot;, chromeOptions))
              {
  
              }
          }
      }
  }
  
  </code></pre>
  <p>If someone can point me in the right direction, I would appreciate it</p>