Watch your case in Linux Containers

By: Chris Dunn

I am subconsciously Windows biased.  Maybe not subconsciously, but I do take case sensitivity and the file system for granted.  I am use to certain path information, special folders names, and file naming conventions. Embarking on the cross-platform possibilities available in .net moving forward, I (and you) will need to rethink some things we take for granted in windows.

I recently ran into a situation while deploying a .Net Core web application to a Linux Docker container. The application was running a SQLite database with the *.db file in a folder off the application root at Data/appdata.db. My Startup.ConfigureServices included the following configuration.

       services.AddDbContext(options =>

Running on my local Windows machine in IIS everything worked great, no problems. When I ran the same application in a Linux Container, I received a database error. File Not Found. I am a little embarrassed to admit that it took me awhile to figure out what was happening.

My windows bias and admitted lack of experience on Linux had blinded me to the case sensitive paths in Linux. A simple change to reference the file in proper case solved the problem.

Now, had I put some additional code in place to check the location of the file, and automatically add the data folder and resulting SQLite file if not found, I would not have run into this situation. But I also would not have learned the valuable lesson of case, that surely would have hit me at another point in the cross platform journey.

Tags: c# linux docker

Copyright 2023 Cidean, LLC. All rights reserved.

Proudly running Umbraco 7. This site is responsive with the help of Foundation 5.