What is Docker container https://www.docker.com/resources/what-container
In simple container is an image or package that will have binaries, configurations etc of the application to run on. Example – In a single OS you can run multiple containers, like CentOS SQL 2017 and 2019 version etc. It is very easy to install, once the image pulled and stored locally, creating SQL server is in a seconds, the advantage is you can create your own images based on the organization standards and store it in Docker HUB. Docker is a container engine developed by Docker to run a containers.
Being SQL server database administrator, mostly we will not worked on Linux platform, I have supported Oracle couple of years and have knowledge of Linux platform.
Following is the 6 steps we are going to test and do ourselves in laptop.
- Install VMware workstation and CentOS
- Install SQL server on Linux CentOS
- Create and install multiple Docker SQL server
- Create volumes with persist data for SQL server database files
- Customize base SQL server image with Docker file
Creating customized SQL container based the organization standard and push to Docker hub.
Create multiple container from Docker file template by using custom SQL server images.
Create multiple SQL server containers creation by using Docker compose with YML script.
- Backup and restore SQL server databases from Linux to windows
- Backup and restore SQL databases from Linux to windows vice versa
Backup your databases from windows server for testing your laptop, export using WinSCP and copy from Linux to container and restore it.
# Backup from windows SQL and restore it on linux container Backup the database & export the backup from windows to Linux Copy from linux to container & restore the database in the container backup database DBAdata to disk ='D:\Backup_Copy\DBAdata.bak' export using winscp if you have container use it or create a new one. docker run -e 'MSSQL_AGENT_ENABLED=True' -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=G0d$peed' -p 1533:1433 --name sql-linux_restoredb -d -h computer-3.broadband mcr.microsoft.com/mssql/server:2019-latest docker cp DBAdata.bak <container id>:DBAdata.bak docker cp DBAdata.bak 3364f39d5989:DBAdata.bak docker exec -it <container id> bash # enter into container and check the file exists docker exec -it 3364f39d5989 bash ls cp DBAdata.bak var/opt/mssql/data/DBAdata.bak exit # connect from ssms and restore it from the file we copied inside the container USE [master] RESTORE filelistonly FROM DISK = N'/var/opt/mssql/data/DBAdata.bak' USE [master] RESTORE DATABASE DBAdata FROM DISK = N'/var/opt/mssql/data/DBAdata.bak' WITH FILE = 1, MOVE N'DBAdata' TO N'/var/opt/mssql/data/PRODUCTION.mdf', MOVE N'DBAdata_log' TO N'/var/opt/mssql/data/PRODUCTION.ldf', NOUNLOAD, STATS = 5 GO
Referred link and videos: Thanks to them for making me to test.
Udemy: Raphael Asghar
YouTube:
https://www.youtube.com/watch?v=LsXQwnnL4bI
https://www.youtube.com/watch?v=Lh6DI6GNxmA