Skip to main content
Version: v23.0

Build the DxEMSSQL Container Image Using Docker

Introduction

DH2i provides a customized DxEnterprise package that is tailored specifically for container deployments. This quick start guide describes how to build a DxEnterprise + SQL Server container image using a pre-made Dockerfile.

Prerequisites

  • A Linux machine with Docker already installed. View Docker documentation for installation instructions.

  • An available repository on Docker Hub.

  • An internet connection for downloading the DxEnterprise container tarball.

Create the SQL Server and DxEnterprise Combined Container Image

First you will create a custom Docker image that combines the SQL Server container image from Docker Hub with a customized DxEnterprise package meant specifically for containers.

  1. Copy the contents of the Dockerfile below to a file your current working directory.

    info

    This image is built from the mcr.microsoft.com/mssql/server:2019-latest image on Docker Hub. This image:

    1. Installs .NET Runtime 6.0 and net-tools. net-tools is not required for the container to run, but it may help with diagnosing network issues.

    2. Copies the latest DxEnterprise tarball from https://repos.dh2i.com/container/, unpacks it, and creates the necessary user permissions.

    3. Assigns the default user as mssql and sets the entrypoint to a pre-defined script. Please note that additional modifications to this script are not supported by DH2i.

    FROM mcr.microsoft.com/mssql/server:2019-latest
    USER root
    #Install dotnet and net-tools
    RUN apt-get update \
    && ACCEPT_EULA=Y apt-get upgrade -y \
    && apt-get install -y wget \
    && wget --no-dns-cache https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
    && dpkg -i packages-microsoft-prod.deb \
    && apt-get update \
    && apt-get install -y dotnet-runtime-6.0 net-tools \
    && dpkg --purge packages-microsoft-prod \
    && apt-get purge -y wget \
    && apt-get clean \
    && rm packages-microsoft-prod.deb \
    && rm -rf /var/lib/apt/lists/*
    #Download and unpack DxE, setup permissions
    ADD https://repos.dh2i.com/container/ ./dxe.tgz
    RUN tar zxvf dxe.tgz && rm dxe.tgz \
    && chown -R mssql /var/opt/mssql \
    && chmod -R 777 /opt/dh2i /etc/dh2i
    #Finish setup
    EXPOSE 7979
    ENV DX_HAS_MSSQLSERVER=1 \
    MSSQL_ENABLE_HADR=1
    USER mssql
    ENTRYPOINT ["/opt/dh2i/sbin/dxstart.sh"]
  2. Replace the <repository_name> variable in the command below the name of your registry, repository, and tag (i.e., dh2i/dxemssql:mytest), and run the command.

    sudo docker build -t <repository_name> -f dxemssql.dockerfile ./

Push the Image to a Repository

Pushing the image to a repository allows you to access the image from locations other than that of the machine it was built on. This step is necessary for deployments in Kubernetes or other cloud platforms.

  1. Login to your Docker account on the local machine using sudo docker login.

  2. Push the image to Docker Hub using the command below, replacing <repository_name> with the tag you used in step 2 of the previous section.

    sudo docker push <repository_name>

Next Steps

Once the image is uploaded to Docker Hub, you can deploy the image in your environment. DH2i has documentation that describes how to use the DxEMSSQL image in various deployments:

Additional Information