I'm trying to bind a host directory to a mssql docker container and have the following [bash] script:
#!/bin/sh
IMPORTDIR=$(cd $(dirname $0); pwd)
DATADIR=${DATADIR:-/tmp/db/}
set -xe
docker run --detach \
-e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Passw0rd" -e "MSSQL_PID=Express" \
-v ${DATADIR}:/mnt/db \
-v ${IMPORTDIR}:/mnt/importing \
-p 127.0.0.1:1433:1433 \
--name mssql-db \
mcr.microsoft.com/mssql/server:latest
sleep 30
docker exec mssql-db /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Passw0rd -Q "
RESTORE FILELISTONLY FROM DISK = '/mnt/db/mssql_db.bak'"
For which I receive the following error message when I run the script:
RESTORE FILELISTONLY FROM DISK = '\''/mnt/db/mssql_db.bak'\'''
Msg 3201, Level 16, State 2, Server cd17fd41ce82, Line 2
Cannot open backup device '/mnt/db/mssql_db.bak'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Server cd17fd41ce82, Line 2
RESTORE FILELIST is terminating abnormally.
When I log into the container I see that indeed the file, which is in the host directory, isn't present is in the container's directory.
The following is my setup info:
Operating System: Mac Os 10.13.6
Docker Version:
File perms (on the host): -rw-r--r--@
I solved this because by adding the real path to /tmp
to the file sharing resource path in docker.
In my OS version (can't comment on the later versions), the /tmp
is a symlink to it's real path /private/tmp
once I added that to the FILE SHARING resources, it worked.
I had just recently upgraded to docker as this wasn't an issue I previously experienced pre-upgrade