How to get started with Microsoft SQL Server on Linux using Docker

Posted on March 3, 2019 by Michael Roma

Below is a command to start a container with port and volume mapping. Replace /Users/username/docker/mssql-data with the local path to use for the volume data

docker run \
     --name mssql-test \
     -d \
     -e 'ACCEPT_EULA=Y' \
     -e 'SA_PASSWORD=StrongP@ssword!' \
     -e 'MSSQL_PID=Express' \
     -p 1433:1433 \
     -v /Users/username/docker/mssql-data:/var/opt/mssql \
     microsoft/mssql-server-linux


Once you have the container running, I recommend using Azure Data Studio to connect and manage the server. Download it here: https://docs.microsoft.com/en-us/sql/azure-data-studio/download?view=sql-server-2017.


To create a database in the default directory:

CREATE DATABASE MyAppDB;


To create a login for the server:

CREATE LOGIN app_user WITH PASSWORD = 'TheStrongP@ssw0rd!';


To create a user in the database for an existing login:

CREATE USER [app_user] FOR LOGIN [app_user];


To give db_owner access to the user:

EXEC sp_addrolemember N'db_owner', N'app_user'


To create a schema:

CREATE SCHEMA App;

Using Build Arguments in Docker Build

Posted on January 8, 2019 by Michael Roma

Example Dockerfile for building an Angular 6 project

# base ===============================
FROM nginx:1.13.3-alpine AS base

# clean up
RUN rm -rf /usr/share/nginx/html/*


# builder ============================
FROM node:10 AS builder

# build dependencies
WORKDIR /app
RUN npm install -g @angular/cli@6.2.3
COPY package.json /app
RUN npm install

# build
ARG BUILDCONF
COPY . /app
RUN ng build --configuration=${BUILDCONF}

# final ==============================
FROM base AS final

# setup server
WORKDIR /app
COPY docker/default.conf /etc/nginx/conf.d/
COPY --from=builder /app/dist /usr/share/nginx/html

CMD ["nginx", "-g", "daemon off;"]

In the dockerfile above, the line for ng build takes a build arg ${BUILDCONF}

RUN ng build --configuration=${BUILDCONF}

You can pass this build arg through the docker build command using the --build-arg parameter

docker build -t my-app:build --build-arg BUILDCONF=$BUILD_CONFIG .

AutoHotKey script for mapping the Apple Key to Control Key

Posted on August 24, 2017 by Michael Roma

Script:

LWin::Ctrl

Fix for git not fetching all branches

Posted on February 26, 2017 by Michael Roma

Below is a fix for if your git fetch does not fetch all branches

First run the following command:

$ git config --get remote.origin.fetch

If the value returned is not equal to:

+refs/heads/*:refs/remotes/origin/*

Then run this to set the config:

$ git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"

SQL Script to find all SQL Agent Jobs for SQL Reporting Services Subscriptions

Posted on December 18, 2016 by Michael Roma
select 
    job.name as SQLAgentJob,
    subscr.SubscriptionID,
    report.Name, 
    report.Path,    
    subscr.Description,
    subscr.LastRunTime,
    subscr.LastStatus

from 
    Subscriptions subscr
    join
    ReportSchedule sched
    on subscr.SubscriptionID = sched.SubscriptionID
    join
    Catalog report
    on sched.ReportID = report.ItemID
    join
    msdb.dbo.sysjobs job
    on cast(sched.ScheduleID as nvarchar(50)) = job.name

order by 
    report.name