我正在尝试将主机目录绑定到 mssql docker 容器并具有以下 [bash] 脚本:
#!/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'"
我在运行脚本时收到以下错误消息:
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.
当我登录到容器时,我看到确实存在于主机目录中的文件不在容器的目录中。
以下是我的设置信息: