How to Install SQL Server with Docker

03.24.2022

Intro

SQL Server is one of the most widely used databases. Microsoft supports this database development and SQL Server has grown to support much more than just SQL. It also can scale up to many terabytes of data easily, making it a safe choice for any project. In this article, we will learn how to install SQL server with Docker.

Installing Docker

For this, we will be using docker. This is recommended for more than just using SQL Server. To find how to install docker go here: https://docs.docker.com/engine/install/

Docker Compose

Now create a file called docker-compose.yml and add the following.

version: "3.9"
services:
  db:
    image: "mcr.microsoft.com/mssql/server"
    ports: 
      - 1433:1433
    environment:
        SA_PASSWORD: "Your_password123"
        ACCEPT_EULA: "Y"

Open a terminal and go to the folder the file is located. Then run the following.

docker-compose up

If you are looking for another good reference, you can check here: https://docs.docker.com/samples/aspnet-mssql-compose/.

Setting up a DB Client

For a database client, I will be using DBeaver. It is open source, https://github.com/dbeaver/dbeaver, has a nice UI and supports many drivers. You can use another client of your choice.

If using DBeaver, step one is to create a new connection

new-connection

Select SQL Server

select-db

Type in the following credentials username SA and Your_password123 as your password. Click "Test Connection" and DBeaver will prompt you to download the drivers if you don't have them.

connection-settings

Finally, let's open up a sql script to run commands.

sqlscript