Skip to content

Commit 1be5147

Browse files
committed
Update SLES15 and OpenSUSE Dockerfiles
1 parent 3d58521 commit 1be5147

File tree

3 files changed

+91
-51
lines changed

3 files changed

+91
-51
lines changed

linux/preview/SLES/README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to build a SQL Server on SLES container image
22

3-
1. Ensure that host machine is running the same version of the SLES that you will build SQL Server 2019 container image, in this case we are using a host which is running SLES 12 SP 5 and building the SQL Server also on top of SLES 12 SP 5.
3+
1. Ensure that host machine is running the same version of the SLES that you will build SQL Server 2019 container image, in this case we are using a host which is running SLES15 SP33 and building the SQL Server also on top of SLES15 SP3.
44

55
2. Please ensure the host machine is registered using the SUSEConnect command as documented here: https://www.suse.com/support/kb/doc/?id=000018564
66

@@ -9,16 +9,31 @@
99
SUSEConnect -s
1010
```
1111
12+
4. Depending on how your host machine is registered, setup your machine for SUSE [container-suseconnect](https://github.com/SUSE/container-suseconnect) correctly so the credentials can be made available to the container. Instructions differ for [RMT/SMT](https://github.com/SUSE/container-suseconnect#building-images-on-sle-systems-registered-with-rmt-or-smt), [on-demand/PAYG in the cloud](https://github.com/SUSE/container-suseconnect#building-images-on-demand-sle-instances-in-the-public-cloud), and [non SLES distros](https://github.com/SUSE/container-suseconnect#building-images-on-non-sle-distributions).
13+
1214
**Steps to building SQL Server on SLES container image**
1315
1416
1. Create the dockerfile as shown in the dockerfile command and save it into your working directory
1517
1618
2. [optional] Customize the mssql.conf file. Example mssql.conf entries can be found here: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-configure-mssql-conf?view=sql-server-2017#mssql-conf-format
1719
18-
3. Build the docker image.
20+
3. Build the docker image.
21+
22+
when host is registered against RMT/SMT
1923
```
2024
docker build . -t mssql-sles-tools-nonroot
2125
```
26+
when host is on-demand or payg in the public cloud
27+
```
28+
docker build --network host -t mssql-sles-tools-nonroot .
29+
```
30+
when using non SLES distros (Note: building on non SLES distros will require [additonal changes](https://github.com/SUSE/container-suseconnect#building-images-on-non-sle-distributions) to the Dockerfile)
31+
```
32+
docker build -t mssql-sles-tools-nonroot \
33+
--secret id=SUSEConnect,src=SUSEConnect \
34+
--secret id=SCCcredentials,src=SCCcredentials .
35+
```
36+
2237
4. Confirm the image is successfully created using the command
2338
```
2439
docker images

linux/preview/SLES/dockerfile

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
##
1+
#
2+
# Note: This image requires an active SLES15 subscription to build.
3+
#
24
# Thank you to our SUSE Partners for helping with this :)
3-
##Assumptions
5+
#
6+
# Assumptions
47
# 1. use a matching version to the underlying build host
58
# 2. ensure it is registered to have access to needed repos
69
# then leveraging container-suseconnect-zypp
@@ -12,50 +15,49 @@
1215
# All repositories have been refreshed.
1316
# 3. minimize the layers by consolidating commands
1417

15-
##
16-
# Base image
17-
##
18-
# Start with the appropriate base image
19-
FROM registry.suse.com/suse/sles12sp5
18+
FROM registry.suse.com/suse/sle15:15.3
2019

21-
# add a needed (beyon minimal) dependency package this package is need so setcap can be used later on to provide the required privilages
22-
RUN zypper in --no-confirm libcap-progs
20+
ENV ADDITIONAL_MODULES=sle-module-legacy
2321

24-
##
25-
# Install the latest SQL 2019 build on SLES
26-
##
27-
# Add product repos / packages
28-
# zypper refresh && \
22+
RUN zypper install --no-confirm --no-recommends \
23+
# install setcap to be used later
24+
# remove openldap2 version lock when https://bugzilla.suse.com/show_bug.cgi?id=1199594 is fixed
25+
# curl is needed for rpm import
26+
libcap-progs openldap2-2.4.46-150200.14.5.1 curl && \
27+
rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
28+
zypper rm --no-confirm --clean-deps curl
2929

30-
RUN zypper addrepo --no-gpgcheck --refresh --check https://packages.microsoft.com/config/sles/12/mssql-server-2019.repo && \
31-
zypper --non-interactive install --no-confirm --auto-agree-with-licenses --auto-agree-with-product-licenses mssql-server
30+
# consider merging the two RUNs to save ~ 40mb at the cost of caching adding the signing key
3231

33-
RUN zypper addrepo --no-gpgcheck --refresh --check https://packages.microsoft.com/config/sles/12/prod.repo && \
34-
ACCEPT_EULA=Y zypper --non-interactive install mssql-tools
32+
# add mssql-server repo
33+
RUN zypper addrepo --no-check https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo && \
34+
zypper refresh packages-microsoft-com-mssql-server-2019 && \
35+
# install mssql-server
36+
zypper install --no-confirm --auto-agree-with-licenses --no-recommends mssql-server && \
37+
# add mssql-tools repo
38+
zypper addrepo --check https://packages.microsoft.com/config/sles/15/prod.repo && \
39+
zypper refresh packages-microsoft-com-prod && \
40+
# install mssql-tools (consider removing to reduce size) Microsoft already maintains a separate mssql-tools image
41+
ACCEPT_EULA=Y zypper install --no-confirm --no-recommends mssql-tools && \
42+
zypper clean --all && \
43+
# post installation of SQL Server the mssql user/group is created
44+
# so set the right permissions to the msssql folder
45+
mkdir -p -m 770 /var/opt/mssql && \
46+
chown -R mssql /var/opt/mssql && \
47+
# grant sql the permissions to connect to ports <1024 as a non-root user
48+
setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr && \
49+
# allow dumps from the non-root process
50+
setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper && \
51+
setcap 'cap_sys_ptrace+ep' /usr/bin/gdb && \
52+
# ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH
53+
# and other env variables that control dynamic linking
54+
mkdir -p /etc/ld.so.conf.d && \
55+
touch /etc/ld.so.conf.d/mssql.conf && \
56+
echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf && \
57+
ldconfig
3558

36-
# post the installation of SQL Server the mssql user/group is created
37-
# so set the right permissions to the msssql folder
38-
#
39-
RUN mkdir -p -m 770 /var/opt/mssql && chown -R mssql. /var/opt/mssql
40-
 
41-
# Grant sql the permissions to connect to ports <1024 as a non-root user
42-
#
43-
RUN setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr
44-
 
45-
# Allow dumps from the non-root process
46-
#
47-
RUN setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper
48-
RUN setcap 'cap_sys_ptrace+ep' /usr/bin/gdb
49-
 
50-
#ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH
51-
# and other env variables that control dynamic linking
52-
#
53-
RUN mkdir -p /etc/ld.so.conf.d && touch /etc/ld.so.conf.d/mssql.conf
54-
RUN echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf
55-
RUN ldconfig
56-
 
5759
EXPOSE 1433
58-
 
60+
5961
USER mssql
60-
 
62+
6163
CMD ["/opt/mssql/bin/sqlservr"]

linux/preview/openSUSE/dockerfile

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
1-
FROM opensuse:42.3
1+
FROM opensuse/leap:15.4
22

3-
RUN zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-preview.repo
3+
RUN zypper install --no-confirm --no-recommends \
4+
# install setcap to be used later
5+
# curl is needed for rpm import
6+
libcap-progs curl && \
7+
rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
8+
zypper rm --no-confirm --clean-deps curl
49

5-
RUN zypper --gpg-auto-import-keys refresh
10+
# consider merging the two RUNs to save ~ 100mb at the cost of caching adding the signing key
611

7-
RUN zypper install -y mssql-server
8-
9-
RUN cp /var/opt/mssql/mssql.conf /
12+
# add mssql-server repo
13+
RUN zypper addrepo --no-check https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo && \
14+
zypper refresh packages-microsoft-com-mssql-server-2019 && \
15+
# install mssql-server
16+
zypper install --no-confirm --auto-agree-with-licenses --no-recommends mssql-server && \
17+
zypper clean --all && \
18+
# post installation of SQL Server the mssql user/group is created
19+
# so set the right permissions to the msssql folder
20+
mkdir -p -m 770 /var/opt/mssql && \
21+
chown -R mssql /var/opt/mssql && \
22+
# grant sql the permissions to connect to ports <1024 as a non-root user
23+
setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr && \
24+
# allow dumps from the non-root process
25+
setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper && \
26+
setcap 'cap_sys_ptrace+ep' /usr/bin/gdb && \
27+
# ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH
28+
# and other env variables that control dynamic linking
29+
mkdir -p /etc/ld.so.conf.d && \
30+
touch /etc/ld.so.conf.d/mssql.conf && \
31+
echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf && \
32+
ldconfig
1033

1134
EXPOSE 1433
1235

13-
ADD ./mssql.conf /var/opt/mssql/
36+
USER mssql
1437

15-
CMD /opt/mssql/bin/sqlservr
38+
CMD ["/opt/mssql/bin/sqlservr"]

0 commit comments

Comments
 (0)