Build the DxEMSSQL Container Image
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 DH2i-provided container build files.
Prerequisites
-
A Linux machine with a supported container runtime installed.
Supported runtimes: Docker or Podman.
Refer to the official Docker or Podman documentation for installation instructions. -
Access to a container image registry (for example, Docker Hub or a private registry) where the built image can be tagged and pushed.
-
An internet connection for downloading the DxEnterprise container tarball.
Create the SQL Server and DxEnterprise Combined Container Image
First you will create a custom container image that combines the SQL Server base image with a customized DxEnterprise package designed specifically for container deployments.
-
Copy the contents of the container build file below to a file in your current working directory.
infoThis image is built from the
mcr.microsoft.com/mssql/server:2019-latestbase image. This image:-
Installs .NET Runtime 8.0 and
net-tools.net-toolsis not required for the container to run, but it may help with diagnosing network issues. -
Downloads the latest DxEnterprise container package from
https://repos.dh2i.com/container/, unpacks it, and configures the required permissions. -
Assigns the default user as
mssqland sets the entrypoint to a pre-defined startup script. 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-8.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"] -
-
Replace the
<repository_name>variable in the command below with the name of your registry, repository, and tag (for example,dh2i/dxemssql:mytest), then build the image.- Docker
- Podman
sudo docker build -t <repository_name> -f dxemssql.dockerfile ./sudo podman build -t <repository_name> -f dxemssql.dockerfile ./
Push the Image to a Repository
When using Podman, image names must be fully qualified with the registry name (for example, docker.io/dh2i/dxemssql).
Pushing the image to a container registry allows you to access the image from systems other than the machine it was built on. This step is required for deployments in Kubernetes or other cloud platforms.
-
Authenticate to your container registry on the local machine.
- Docker
- Podman
sudo docker loginsudo podman login docker.io -
Push the image to the registry, replacing
<repository_name>with the image tag you used in the previous section.- Docker
- Podman
sudo docker push <repository_name>sudo podman push <repository_name>
Next Steps
Once the image is uploaded to a container registry, you can deploy it in your environment. DH2i provides documentation that describes how to use the DxEMSSQL image in various deployment scenarios: