MSSQL Server exiting after RUN command

Hi,
I set up a MSSQL Server 2019 container, now I want to run tho container with the following command:
docker run -e “ACCEPT_EULA=Y” -e “SA_PASSWORD=myPassword”
-p 1433:1433 --name MSSQLSERVER
-v /home/docker/dockervolumes/MSSQL/:/var/opt/mssql
-d Microsoft Artifact Registry --restart=always

But the container exits after startup, the log says:
SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
To learn more visit Deploy and connect to SQL Server Linux containers - SQL Server | Microsoft Learn.
/opt/mssql/bin/permissions_check.sh: line 59: exec: --: invalid option
exec: usage: exec [-cl] [-a name] [command [arguments …]] [redirection …]

What’s wrong in the run statement?

On the host system a user docker with the home folder exists.

thx
djuecat

Hi, I’ve just started with playing around with docker, so I don’t know much, still, I had the same error message you had, and I managed to work around it by running the user as root using the argument -u 0:0

My guess is that the user doesn’t have the permissions it needs, and that is why running as root fixes it

Hi, that doesn’t work for me. Are you using SQL Server 2017 or 2019?

I think the problem is in the generated exec command within the file permissions_check.sh:

#Execute the cmd from the dockerfile
> exec “$@”

The ouput from log is:

SQL Server 2019 will run as non-root by default.
This container is running as user mssql.
Your master database file is owned by root.
To learn more visit Deploy and connect to SQL Server Linux containers - SQL Server | Microsoft Learn.
/opt/mssql/bin/permissions_check.sh: line 59: exec: --: invalid option
> exec: usage: exec [-cl] [-a name] [command [arguments …]] [redirection …]

So what’s the exact command which is executed in the last line of the permissions_check.sh???

Hi,

--restart=always cant be the end of the sentence.

you can try this

docker run -e “ACCEPT_EULA=Y” -e “SA_PASSWORD=myPassword”
-p 1433:1433  --restart=always --name MSSQLSERVER
-v /home/docker/dockervolumes/MSSQL/:/var/opt/mssql
-d [mcr.microsoft.com/mssql/server:2019-latest](http://mcr.microsoft.com/mssql/server:2019-latest)
1 Like

thank you this worked!

Had the same issue. --restart=always isn’t the solution.
Rather my Password didn’t full fill the requirements.

See box under Step 2: Docker: Install containers for SQL Server on Linux - SQL Server | Microsoft Learn

:information_source: Note

The password should follow the SQL Server default password policy, otherwise the container can not setup SQL server and will stop working. By default, the password must be at least 8 characters long and contain characters from three of the following four sets: Uppercase letters, Lowercase letters, Base 10 digits, and Symbols. You can examine the error log by executing the docker logs command.

3 Likes

Restarting isnt a solution as it just gets the container running in loop after container stops after permission error