Skip to content

Commit 3d58521

Browse files
authored
Merge pull request #750 from VanMSFT/patch-1
Adding custom SQL Server 2019 Docker file
2 parents 0e12922 + 0ebee1b commit 3d58521

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Base OS layer: Latest Ubuntu LTS
2+
FROM mcr.microsoft.com/mssql/server:2019-latest
3+
USER root
4+
# Install prerequistes since it is needed to get repo config for SQL server
5+
RUN apt-get update && \
6+
apt-get install -y software-properties-common && \
7+
rm -rf /var/lib/apt/lists/*
8+
RUN add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)" && \
9+
apt-get install -y mssql-server-fts && \
10+
apt-get install -y mssql-server-polybase
11+
12+
EXPOSE 1433
13+
14+
USER mssql
15+
16+
# Run SQL Server process
17+
CMD ["/opt/mssql/bin/sqlservr"]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SQL Server 2019 on RHEL 7 sample script
2+
# This is a sample script shared to help create the SQL Server 2019 containers images based on RHEL 7
3+
# This script can be modified to add other SQL Server components like polybase, Full text search, and others.
4+
# Base OS layer: latest RHEL 7 latest image
5+
FROM registry.access.redhat.com/rhel7:latest
6+
7+
## Adding the required repos for installing SQL Server, tools, and other dependent packages.
8+
RUN REPOLIST=rhel-7-server-rpms,packages-microsoft-com-mssql-server-2019,packages-microsoft-com-prod && \
9+
curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo && \
10+
curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo && \
11+
ACCEPT_EULA=Y yum -y install --disablerepo "*" --enablerepo ${REPOLIST} --setopt=tsflags=nodocs \
12+
mssql-server mssql-tools unixODBC-devel && \
13+
yum clean all
14+
15+
## Providing the required access to the mssql server folders
16+
RUN mkdir -p -m 770 /var/opt/mssql && chown -R mssql. /var/opt/mssql
17+
18+
## Default SQL Server port
19+
EXPOSE 1433
20+
21+
## Running SQL containers as non-root
22+
USER mssql
23+
24+
## Start SQL server
25+
CMD /opt/mssql/bin/sqlservr
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SQL Server 2017 on RHEL 8 ubi Sample
2+
# This is a sample script shared to help create the SQL Server 2017 containers images based on RHEL 8
3+
# This script can be modified to add other SQL Server components like polybase, Full text search, and others.
4+
# Base OS layer: latest RHEL 8 ubi image
5+
FROM registry.access.redhat.com/ubi8:latest
6+
7+
# You need to ensure that the host where you are building this image has repos subscribed that are required to install the package dependencies, like python3, bzip2, and many more.
8+
# Adding repositories and installing SQL Server and tools packages
9+
RUN REPOLIST=rhel-8-for-x86_64-baseos-rpms,rhel-8-for-x86_64-appstream-rpms,packages-microsoft-com-mssql-server-2017,packages-microsoft-com-prod && \
10+
curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2017.repo && \
11+
curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo && \
12+
ACCEPT_EULA=Y yum -y install --disablerepo "*" --enablerepo ${REPOLIST} --setopt=tsflags=nodocs \
13+
mssql-server mssql-tools unixODBC-devel && \
14+
yum clean all
15+
16+
## Adding the required non-root mssql user and also giving access to the mssql server folders
17+
RUN useradd -M -s /bin/bash -u 10001 -g 0 mssql
18+
RUN mkdir -p -m 770 /var/opt/mssql && chown -R mssql. /var/opt/mssql
19+
20+
## Containers not to be run as root, so accessing it as mssql user.
21+
USER mssql
22+
23+
# Default SQL Server TCP/Port
24+
EXPOSE 1433
25+
26+
# Run SQL Server binary
27+
CMD ["/opt/mssql/bin/sqlservr"]

0 commit comments

Comments
 (0)