There are two ways of spinning up the container:
Three environment variables are needed when creating the container.
ACCEPT_EULA=Y
SA_PASSWORD=<your_strong_password>
MSSQL_PID=<edition_name> (default: Developer)
docker container run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<password>" -e "MSSQL_PID=Developer" -p <port>:1433 --name sqlserver boshoffwillem/sql-server:latest
You'll probably want to persist the SQL data of the container in case the container crashes. Just start the container and bind the data to a volume (docker will create the volume if it doesn't exist).
docker container run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<password>" -e "MSSQL_PID=Developer" -p <port>:1433 --name sqlserver -v <volume-name>:/var/opt/mssql boshoffwillem/sql-server:latest
If you want to import existing SQL data you have into the container you're going to spin up follow these steps:
At the least, you need the .bak file of each DB you want to import into the container.
docker container run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<password>" -e "MSSQL_PID=Developer" -p <port>:1433 --name sqlserver -v <volume-name>:/var/opt/mssql boshoffwillem/sql-server:latest
docker cp <db-backup>.bak <volume-name>:/var/opt/mssql/backup
You'll need to execute the following query to tell SQL Server to import the backup files. The easiest way to do it is to connect to the server with a DB program like Azure Data Studio. The connection string will be hostname,port
For example
localhost,11433
RESTORE FILELISTONLY
FROM DISK = '/var/opt/mssql/backup/<db-backup>.bak'
The following query will create a DB from the backup file.
RESTORE FILELISTONLY
FROM DISK = '/var/opt/mssql/backup/<db-backup>.bak'
RESTORE DATABASE <DB_NAME>
FROM DISK = '/var/opt/mssql/backup/<db-backup>.bak'
WITH
MOVE '<DB_NAME>' TO '/var/opt/mssql/data/<DB_NAME>.mdf',
MOVE '<DB_NAME>_Log' TO '/var/opt/mssql/data/<DB_NAME>.ldf'
If you want to create backup files for the SQL data in your container, execute the following query.
BACKUP DATABASE [<DB_NAME>]
TO DISK = N'/var/opt/mssql/backup/<db-backup>.bak'
WITH NOFORMAT,
NOINIT,
NAME = '<DB_NAME>', SKIP, NOREWIND, NOUNLOAD, STATS = 10
docker cp <volume-name>:/var/opt/mssql/backup/<db-backup>.bak <db-backup>.bak
Content type
Image
Digest
Size
471.2 MB
Last updated
about 5 years ago
docker pull boshoffwillem/sql-server