Run SQL Server in a Windows Docker container - Step by Step

Thanks to all those who have given details in bits and pieces via videos, blogs.

I want to set up SQL Server on Docker on Windows. Below is the step by step guide to achieving the same.

Step 1: Download and Setup Docker for Windows

Download Docker for Desktop from Link "https://hub.docker.com/?overlay=onboarding", You will get the file "Docker Desktop Installer.exe"

Step 2: Run the setup as admin

This will download docker files in folder "C:\Program Files\Docker\Docker" and then install docker.


Step 3: Open Power shell as admin and run below commands, Once installation completed (I have selected install for windows)

Command 1:  docker run hello-world      à This will install image of hello world program from docker hub
Command 2: docker --version                    à This will give a version of docker
Command 3: docker image ls                      à This will list all images  available in docker (even if not used)
Command 4: docker container ls -all        à This will list all containers setup on docker



In the docker hub, you can upload images or download images required for use.

Step 4: Let's download the SQL server image from the docker hub. 

Command: docker pull microsoft/mssql-server-windows-developer:2017-latest




Step 6: let's verify  images
Command: docker image ls


Step 7: Let's install SQL Server 2017 image downloaded

Syntax: docker run -d –p <Port> –name <FriendlyName> -e sa_password=<Password> -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer:2017-latest
Command: docker run -d –p 1433:1433 –name  sql1  -e sa_password=Adil@123 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer:2017-latest

Here we mention port twice, First for Local machine second for the container. In case you want to create multiple SQL servers, Please use different ports



This will install SQL 2017 and start the service. To monitor from GUI you can also use tool "Kitematck" from https://github.com/docker/kitematic/releases


Step 8. Now let's assign IP so we can access SQL Server  from SSMS

Command: docker inspect --format '{{.NetworkSettings.Networks.nat.IPAddress}}' sql1


Step 9: Let's use IP to connect from SQL Server (Make sure SSMS is installed). Open SSMS






Step 10. Executing my first query.




Now we are good with SQL Server. This will be very helpful for

1. Setting testing and development environments
2. Setting up environments for training.





No comments:
Write comments

Services

More Services


© 2014 Education Tutorials. Designed by Bloggertheme9
Powered by Blogger.