William Leme

Software Engineer

Installing SqlServer on Linux

Posted at — Dec 8, 2018

In this tutorial we will pull a Sql Server docker image, create a docker-compose script and connect to this new server using SSMS (sql server management studio)

I keep all my databases, queues and other infrastructure tools on a linux box running as docker containers. Docker gives me the flexibility of installing multiple things without messing up my dev environment and I recently added SqlServer

Pull the docker image into your linux box

sudo docker pull mcr.microsoft.com/mssql/server

Install docker compose (if you don’t have it)

sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Create a new docker-compose.yml file

sudo nano docker-compose.yml
and type the following: (The configuration below will run the sql server container in the developer edition)
version: '3'
services:
  sqlserver:
    image: mcr.microsoft.com/mssql/server:latest
    container_name: sqlserver1
    restart: always
    environment:
      - "ACCEPT_EULA=Y"
      - "MSSQL_SA_PASSWORD=<YourStrong!Passw0rd>"
    volumes:
      - ./data/sqlserver1/:/var/opt/mssql
    ports:
      - "1433:1433"

now we can start docker compose

sudo docker-compose up

and make sure sql server is up

sudo docker ps -a
you should see the following ![alt text](/imgs/0002 - sql server on linux.jpg “SqlServer”)

Connecting via SSMS

Now that the server is up and running and the container is exposed to connections outside the docker, we are able to use it normally and connect to it via SSMS or our application.