How to run dotnet core app with Selenium in Docker

I have dotnet core 2.2 (aspnet core) app running in Docker container. I’m using the simplest possible Dockerfile you can find in any basic tutorial:

  • use microsoft/dotnet:2.2-sdk as base image
  • copy *.csproj
  • restore packages
  • build
  • publish to /app folder
  • use microsoft/dotnet:2.2.1-aspnetcore-runtime to run the app from /app folder

Now I’d like to grab some data from another website. It is a SPA, so I need to use a browser to render the page first – I decided to use Selenium with ChromeDriver because I’m already a little bit familiar with them.

I’ve added Selenium.WebDriver v3.141 and Selenium.WebDriver.ChromeDriver v73.0 to my project, set Selenium there. Locally on Windows it works fine. But when I run this via Docker I’m getting:

The file /app/chromedriver does not exist. The driver can be downloaded at

So now I’m wondering how can I run Selenium + single instance Chrome (there is no need to set up Selenium Grid for my purpose) with dotnet core 2.2 in Docker.

I suppose I need to create custom Dockerfile which:

  • installs selenium, chrome and all their dependencies
  • installs dotnet
  • does the same as my current Dockerfile to build and run my app

But I’m not really sure how to do this. Especially how to “nest” Dockerfiles.
Should I do this composition in a single Dockerfile? Should I create Dockerfile for Selenium + ChromeDriver and use it as base image for next step?

Source: StackOverflow