I found a lot of cases, where people try to open a file from outside the docker container. But mine is clearly inside.
The whole message I am getting is:
$ /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "mypw" -Q
"RESTORE FILELISTONLY FROM DISK = '/var/opt/mssql/backup/MyDB.bak'"
Msg 3201, Level 16, State 2, Server 1c7bf85afdaf, Line 1
Cannot open backup device '/var/opt/mssql/backup/MyDB.bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Server 1c7bf85afdaf, Line 1
RESTORE FILELIST is terminating abnormally.
Same happens when I try to actually restore the database. Any idea what is going wrong?
I have the feeling it might be some permission things where need to change permissions for the file
$ ls -la var/opt/mssql/backup/MyDB.bak
-rw-r----- 1 501 dialout 3395584 Jan 16 02:12 var/opt/mssql/backup/MyDB.bak
However, in the majority of cases, “System error 5 has occurred' emerges due to the lack of administrative privileges. Even if the PC user is logged into the system as an administrator, Command Prompt may deny access if it is not run as administrator.
The solution was to change the permission of the file. I needed to do:
docker exec -it -u root MicrosoftSQLServer "bash"
Then change the user (whoami
returns mssql
when I run the docker container not as root)
chown mssql /var/opt/mssql/backup/TestDB.bak
And then it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With