Run SQL Server in Docker container

SQL server

  • Sql Server is one of most populare relation database technologie devloped by Microsoft. Its use to store and retrive, it used by applications that support transactional and analytical workloads.

create image for Sql server :

First you must have Docker install in your machine if not check this link :docker

to run sql server create a file named docker-compose.yml in folder of your project

version: "3.3"

services :
  sqldata:
    image: mcr.microsoft.com/mssql/server
    environment:
      - SA_PASSWORD=Pass@word
      - ACCEPT_EULA=Y
    ports:
      - "1433:1433"

To lunch our db, we can run commande from commande line :
$ docker-compose up -d
After docker pullin the image and service run you can check if the information about the image by this commande :
$ docker ps
image

We can now acces to our container by passing to mode bash of our image :

$ docker exec -it 'name_of_image' 'bash'

After execute the image in mode bash you can connecte to database using sqlcmd :

/opt/mssql-tools/bin/sqlcmd -U SA -P Pass@word
image

16