How to import .bacpac into docker Sqlserver? How to import .bacpac into docker Sqlserver? docker docker

How to import .bacpac into docker Sqlserver?


Hi all! We finally have a preview ready for sqlpackage that is built on dotnet core and is cross-platform! Below are the links to download from. They are evergreen links, i.e. each day a new build is uploaded. This way any checked in bug fix is available the next day. Included in the .zip file is the preview EULA.linuxhttps://go.microsoft.com/fwlink/?linkid=873926osxhttps://go.microsoft.com/fwlink/?linkid=873927windowshttps://go.microsoft.com/fwlink/?linkid=873928Release notes:

The /p:CommandTimeout parameter is hardcoded to 120Build and deployment contributors are not supporteda. Need to move to .NET Core 2.1 where System.ComponentModel.Composition.dll is supportedb. Need to handle case-sensitive pathsSQL CLR UDT types are not supported.a. This includes SQL Server Types SqlGeography, SqlGeometry, & SqlHierarchyIdOlder .dacpac and .bacpac files that use Json serialization are not supportedReferenced .dacpacs (e.g. master.dacpac) may not resolve due to issues with case-sensitive file systems

For lack of a better method, please provide any feedback you have here on this GitHub issue.

Thanks for giving it a try and letting us know how it goes!

https://github.com/Microsoft/mssql-docker/issues/135#issuecomment-389245587

EDIT: I've made you a Docker image for this

https://hub.docker.com/r/samuelmarks/mssql-server-fts-sqlpackage-linux/

Example of setting up a container, creating a database, copying a .bacpac file over, and importing it into aforementioned database:

docker run -d -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' -p 1433:1433 --name sqlfts0 samuelmarks/mssql-server-fts-sqlpackage-linuxdocker exec -it sqlfts0 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourStrong!Passw0rd>' -Q 'CREATE DATABASE MyDb0'docker cp ~/Downloads/foo.bacpac sqlfts0:/opt/downloads/foo.bacpacdocker exec -it sqlfts0 dotnet /opt/sqlpackage/sqlpackage.dll /tsn:localhost /tu:SA /tp:'<YourStrong!Passw0rd>' /A:Import /tdn:MyDb0 /sf:foo.bacpac


It looks like Microsoft has implemented support of this on sqlpackage, with documentation!

You will have to add sqlpackage to your container.

You can download it here. (optionally, direct link to linux package here, hopefully doesn't change)

The following are instructions for running this from a windows machine -- obviously it's the bare minimum to get it working. Please change passwords, and probably put this in a docker-compose.yml for re-use.

I unzip the above package into a folder 'c:\sqlpackage' (my windows docker run doesn't allow relative paths), and then mount that into the container with the bacpac, like such:

docker run -d -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Asdf1234" -v c:\sqlpackage:/opt/sqlpackage -v c:\yourdb.bacpac:/tmp/yourdb.bacpac -p 1433:1433 --name mssql-server-example microsoft/mssql-server-linux:2017-latest

here is what a *nix user could run alternatively:

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 to your container and run:

/opt/sqlpackage/sqlpackage /a:Import /tsn:. /tdn:targetdbname /tu:sa /tp:Asdf1234 /sf:/tmp/yourdb.bacpac

After this, you should be able to connect with SSMS to localhost, username and password as you provide them above, and see 'targetdbname'! These are mostly notes I wrote for myself but I'm sure others could use them too.


This is not a supported feature with a LINUX implementation it seems.

See this link.