It looks like Microsoft has implemented support for this in sqlpackage, with the documentation !
You will need to add sqlpackage to your container.
You can download it here. (optional, a direct link to the linux package here , hopefully, will not change)
Below are instructions for starting this from a Windows machine - obviously this is the minimum to get it working. Please change the passwords and probably put them in docker-compose.yml for reuse.
I unpack the above package into the "c: \ sqlpackage" folder (my launch of Windows Docker does not allow relative paths) and then mount it in a container with bacpac , for example:
docker run -d -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Asdf1234" -vc:\sqlpackage:/opt/sqlpackage -vc:\yourdb.bacpac:/tmp/yourdb.bacpac -p 1433:1433 --name mssql-server-example microsoft/mssql-server-linux:2017-latest
here is what * nix user can * alternatively run:
docker run -d -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Asdf1234' -v ./sqlpackage:/opt/sqlpackage -v ./yourdb.bacpac:/tmp/yourdb.bacpac -p 1433:1433 --name mssql-server-example microsoft/mssql-server-linux:2017-latest
and finally attach it to the container and run:
/opt/sqlpackage/sqlpackage /a:Import /tsn:. /tdn:targetdbname /tu:sa /tp:Asdf1234 /sf:/tmp/yourdb.bacpac
After that, you can connect to SSMS with localhost, username and password, as you indicated above, and see "targettdbname"! These are mainly notes that I wrote for myself, but I'm sure others can use them too.
source share