Writing docker hosted .NET Core applications with IBM Data Server provider
VishDev2018 50232PFTJ6 Visits (8554)
Microsoft Visual Studio 2017 supports writing applications which runs on Docker. Docker for Windows is available for install at
This article explains how to create a simple Console application using IBM Data Server Driver for .NET Core and run the application on Docker for Linux. For Windows specific containers please refer the blog here.
Open Visual Studio 2017 and create new Console application from Start-> New -> Project -> Installed -> Visual C# -> .NET Core -> Console App(.NET Core).
NOTE : Remember this path since we need to open a Power Shell command prompt for compiling and running the application from the same path.
Once the project is created, right click on the project Dependencies and add IBM .NET Core provider for Linux package from NuGet repository:
Next, add Docker support by right clicking on the project and doing a Add-> New->Docker Support
When prompted, select Linux as the required Operating System.
Right click on Dependencies -> Properties, locate and browse to the physical location of IBM .NET Core package . From this location copy the clidriver folder to the Project folder. "C:\
On some docker machines, one of the dependency file libxml2.so.2 may be missing. In that case, download this file and link it to libdb2.so. The downloaded file should be copied either to system lib folder inside the docker or it can be copied inside clidriver\lib folder.
For linking, in the Program.cs file, inside the Main method, include code to execute the following bash command :
Next, modify the content of the DockerFile in the ConsoleApp1 as follows:
In the above listing, position of the highlighted text is important for setting the values for the right container.
Open a Power Shell command prompt with Administrative Privileges by doing a right click and using Run As Administrator option.
Browse to the folder where the docker file of the ConsoleApp1 is present and execute the following command to build\
docker build -t mycontainer .
Notice the dot at the end of above command.
If successfully built, execute the following command to run the ConsoleApp
docker run mycontainer
We should see a "hello world" as the output of this sample.
We can now try adding some IBM Data Provider specific code to test connectivity to a database.
Repeat the build and run command from Shell script as explained earlier and test the outcome.
[Last modified on 1st of July 2019.]