Posted in: Docker

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 .