Run docker container with custom user - jenkinspipeline with docker build agent

I have a .Net Console App using .Net Framework 4.7.2. We are migrating CI/CD build and deployment of this application from TeamCity to Jenkins Pipeline using jenkinsfile. I am using a windows docker image (vsbuildtools2019-16.4-managed-desktop:3.5-4.8-dotnet-framework-10.0.14393.2485) to build my application. When it comes to deployment we are using company’s internal package builder (.exe - a software which packages the application and deploys to servers).

Its limitation is that it can only be run via specific user accounts which have access to drop the final package to the deployment network shares and some further processing happens after that.

The issue i am facing is that by default the user profile which the container uses is “C:/Users/ContainerAdministrator” or when I try to find the username it gives me the <Servername$> as the name of the user. I want to run the container using a Service Account which has access to those network share. How can i achieve that ?

Below is how I am using jenkinsfile to get the container on the Jenkins Build agent :-

agent {
  docker {
    image <docker-image>
    label 'docker-win'
    reuseNode true
}

Hi, Can you please help on this one ?

Does anyone has any thoughts on this please ? This is proving to be a blocker for me.

It was a month ago. Could you solve it? Did you want to use a user account from your host operating system? I guess not many people use Docker on Windows at this level. I don’t know much about it either, but if you can mount credential files inside the container (which is probably a HyperV VM on Windows), you might be able to do what you want. I found this. I don’t know if it helps. Run a container with a gMSA | Microsoft Docs

@remelel Thanks for replying. I could not figure out a straight way to run the container using specific user account. The link you have provided (gMSA) is not setup in my organisation and may not be allowed at this point.

But what I have done is that I have mapped the network location as a network drive where I have to dropoff the release package from the container. It took me some out of the way solutions by changing the deployment software configuration but its doing the job now. I hope docker windows matures with time and provide features like these which maybe very handy for the users.