Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use windows authentication with SQL server docker container

I have gone through all the examples I could find online for building docker container based applications. I would want to run two services running in two docker containers:

  1. A windows container running ASP.NET
  2. A windows container running SQL Server

Easy job and many examples. However, in all examples you need to use SQL authentication and to provide a hard-coded SA password as an environment variable when running the SQL server container. You also need to hard code the SA password into the connection string in the ASP.Net code (or also provide it in some other manner in a configuration file, etc.)

Bottom line in all examples the password is hard-coded somewhere.

In most applications we develop now, we actually use windows authentication instead or use a grouped managed service account instead. But as far as I know, you cannot add a windows container to a domain, thus the SQL server is not part of the windows domain so I don't see a way to use windows authentication here.

So does any one have an alternative to hard-coding passwords this way ?

like image 410
IProgrammer Avatar asked Dec 30 '16 15:12

IProgrammer


People also ask

Can SQL Server use Windows Authentication?

A connection made using Windows Authentication is sometimes called a trusted connection, because SQL Server trusts the credentials provided by Windows. By using Windows Authentication, Windows groups can be created at the domain level, and a login can be created on SQL Server for the entire group.

How do I connect to SQL Server using Windows Authentication?

Open SQL Server Management Studio. In Connect to Server, select Database Engine, enter your SQL Server name, and enter administrator credentials to connect to the server. Select Connect. In Object Explorer, expand the SQL Server, expand Security, right-click Logins, and then select New Login.


1 Answers

I'm dealing exactly with the same problem. Here is the most complete procedure that I found. The trick is to use gMSA.

But, as JanneRantala says at the end, I'm having the same problem when trying to add a new User in the Database :

Msg 15401, Level 16, State 1, Line 3 Windows NT user or group 'YOUR_DOMAIN\gmsa$' not found. Check the name again.

like image 120
G. Gomes Avatar answered Sep 21 '22 08:09

G. Gomes