In this post I will show you how you can easily run Microsoft ms SQL Server" ms docker docker-compose. You won’t believe how simple it is! You will have a ready-to-work environment in just a few minutes! Try it yourself!
SQL Server": Microsoft provides official images in docker" hub, so you can just pull and create container based on them.
Table of Contents
Microsoft" SQL Server" is a popular relational database" management system (RDBMS) that is used to store and manage data. It is designed to be fast, reliable, and easy to use, and it supports a wide range of programming" languages and development platforms.
SQL Server" is commonly used for web-based applications, data warehouses, and other applications that require fast, reliable data storage and retrieval. It supports a variety of data types, including text, numbers, and binary data, and it provides a number of features for indexing, querying, and manipulating data.
To use SQL Server", you will need to install it on a server and create a database. You can then use SQL" (Structured Query Language) to create tables, insert and modify data, and run queries against the database. SQL Server" also provides a number of tools and features for managing and monitoring the database, including backup and recovery, security, and performance monitoring.
There are several editions of SQL Server" available, including Express, Standard, and Enterprise, which offer different levels of features and scalability. You can find more information about SQL Server" in the Microsoft" documentation and online resources.
A Docker image" is a lightweight, stand-alone, executable package that includes everything needed to run a piece of software, including the application code, libraries, dependencies, and runtime. Docker" images are used to create Docker" containers, which are lightweight and portable environments that can be run on any system that has Docker" installed.
To create a Docker image", you will need to write a Dockerfile", which is a text file that specifies the instructions for building the image. The Dockerfile" includes commands to specify the base image to use, any additional packages or libraries to install, and any other necessary configuration.
Once you have written your Dockerfile", you can use the
docker build command to build the image. This will create a new Docker image" that you can use to create Docker" containers.
You can find more information about Docker" images and how to create them in the Docker" documentation. There are also many resources available online that can help you learn more about using Docker" and creating Docker" images.
Firstly we will create the recipe for docker-compose". Let’s create YML file and put inside the below configuration. In this example we will take the latest tag of SQL Server 2019.
Additionally we must set the password which we will use to connect to database, accept the EULA and provide information which Product ID you want to use. Options are:
- Developer : This will run the container using the Developer Edition (this is the default" if no MSSQL_PID environment variable is supplied)
- Express : This will run the container using the Express Edition
- Standard : This will run the container using the Standard Edition
- Enterprise : This will run the container using the Enterprise Edition
- EnterpriseCore : This will run the container using the Enterprise Edition Core : This will run the container with the edition that is associated with the PID (all the information is coming from official website on DockerHub)
version: "3" services: sql-server: image: mcr.microsoft.com/mssql/server:2019-latest hostname: sql-server container_name: sql-server ports: - "1433:1433" environment: - ACCEPT_EULA=Y - SA_PASSWORD=yourStrong(!)Password - MSSQL_PID=Express
Tu run container please just execute command below. Docker image" will be downloaded and run.
docker-compose up Pulling jenkins (mcr.microsoft.com/mssql/server:2019-latest)... 2019-latest: Pulling from mssql/server 5b7339215d1d: Already exists 14ca88e9f672: Already exists a31c3b1caad4: Already exists b054a26005b7: Already exists 59f979819d9b: Pull complete 29eb18117119: Pull complete 6de3c1cf897f: Pull complete 172ea0155639: Pull complete Digest: sha256:e064843673f08f22192c044ffa6a594b0670a3eb3f9ff7568dd7a65a698fc4d6 Status: Downloaded newer image for mcr.microsoft.com/mssql/server:2019-latest
Connect To Database
Now I will show you how you can connect to SQL Server Database. In my case I will use the DBeaver" Community.
Let’s open DBeaver", choose “create new connection”, select SQL Server" from the list and click Next. (Microsoft" ms SQL Server" ms Docker" docker-compose")
In next window provide information like:
- Host: localhost
- Port: 1433
- Database/Schema: master
- Authentication: SQL Server" Authentication
- User" name: sa
- Password: yourStrong(!)Password (from docker-compose".yml file)
Now we can test our connection using “Test Connection …” button in left bottom part of window. If everything was set correctly you should see information like below:
Server: Microsoft SQL Server 15.00.4023 Microsoft SQL Server 2019 (RTM-CU3) (KB4538853) - 15.0.4023.6 (X64) Mar 4 2020 00:59:26 Copyright (C) 2019 Microsoft Corporation Express Edition (64-bit) on Linux (Ubuntu 18.04.4 LTS) <X64> Driver: Microsoft JDBC Driver 8.2 for SQL Server 220.127.116.11
Run Test SQL Query
At the and of this post we will execute simple SQL" query to get some data from database. We will use existing table from master database. (Microsoft" ms SQL Server" ms Docker" docker-compose")
SELECT * FROM master.dbo.spt_values;
That’s all about How to run Microsoft" ms SQL Server" ms Docker" docker-compose". Enjoy!
Could You Please Share This Post? I appreciate It And Thank YOU! :) Have A Nice Day!
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?