"No such file or directory" exception when initializing Chrome Driver in Docker container

236 views
Skip to first unread message

Stephen Bates

unread,
Dec 1, 2021, 11:06:29 AM12/1/21
to Selenium Users
We have a project written in .NET (specifically .NET Core 3.1) using Selenium, and we build an Alpine Linux Docker image from that app. The Selenium.WebDriver.ChromeDriver Nuget package is added to the solution to ensure that the chromedriver is copied to the build directory. 

We have the following code for initializing the driver:

var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); var driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(path), chromeOptions, chromeSettings.Value.CreativePageLoadTimeout);

Whenever this code is run, we get the following error message:

[10:05:06 ERR] An unexpected error occurred while processing a request System.ComponentModel.Win32Exception (2): No such file or directory at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at OpenQA.Selenium.DriverService.Start() at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities) at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)

We've confirmed that the "chromedriver" file does indeed exist in the specified directory by SSHing into the Docker container. We have also tried not specifying a path, specifying the root path, and many other combinations but they all result in the same problem. The Chrome version is 96.

If the project is debugged locally in Windows (ie. not running within a Linux Docker instance) then everything works as expected.

Ned Thompson

unread,
Dec 3, 2021, 5:16:15 AM12/3/21
to Selenium Users
What is the path of Chrome?

Ned Thompson

unread,
Dec 5, 2021, 11:40:15 PM12/5/21
to Selenium Users
Apologies for the open ended question at first. I was wondering how you could know that the Chrome version was 96, as it seems like there aren't any Chrome packages available for Alpine. Looks like they just pushed Chromium 96 today, so you could try it with that. https://pkgs.alpinelinux.org/packages?name=chromium&branch=edge

I would also check to make sure that whatever "path" resolves to when running the container is delimited by a forward slash instead of a backslash. You could do this by writing path to the console then running it on that container. Maybe try:
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); 
if that is the case.
Reply all
Reply to author
Forward
0 new messages