Docker Community Forums

Share and learn in the Docker community.

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 mcr.microsoft.com/mssql/server:2019-latest --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 https://go.microsoft.com/fwlink/?linkid=2099216.
/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 https://go.microsoft.com/fwlink/?linkid=2099216.
/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!