Skip to content

Commit d145a4f

Browse files
authored
Merge pull request microsoft#759 from jamesongithub/jy/dockerfiles
Update SLES Dockerfile to 15.3. Update OpenSUSE Dockerfile to use leap15.4. Reduce image layers. Update instructions for building on registered host.
2 parents 3d58521 + 1df53da commit d145a4f

File tree

5 files changed

+117
-78
lines changed

5 files changed

+117
-78
lines changed

linux/preview/SLES/Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#
2+
# Note: This image requires an active SLES15 subscription to build.
3+
#
4+
# Thank you to our SUSE Partners for helping with this :)
5+
#
6+
# Assumptions
7+
# 1. use a matching version to the underlying build host
8+
# 2. ensure it is registered to have access to needed repos
9+
# then leveraging container-suseconnect-zypp
10+
# e.g. zypper ref
11+
# Repository 'SLE-Module-Containers12-Pool' is up to date.
12+
# Repository 'SLE-Module-Containers12-Updates' is up to date.
13+
# Repository 'SLES12-SP5-Pool' is up to date.
14+
# Repository 'SLES12-SP5-Updates' is up to date.
15+
# All repositories have been refreshed.
16+
# 3. minimize the layers by consolidating commands
17+
18+
FROM registry.suse.com/suse/sle15:15.3
19+
20+
ENV ADDITIONAL_MODULES=sle-module-legacy
21+
22+
RUN zypper install --no-confirm --no-recommends \
23+
# install setcap to be used later
24+
# curl is needed for rpm import
25+
libcap-progs curl && \
26+
rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
27+
zypper rm --no-confirm --clean-deps curl
28+
29+
# consider merging the two RUNs to save ~ 40mb at the cost of caching adding the signing key
30+
31+
# add mssql-server repo
32+
RUN zypper addrepo --no-check https://packages.microsoft.com/config/sles/15/mssql-server-2019.repo && \
33+
zypper refresh packages-microsoft-com-mssql-server-2019 && \
34+
# install mssql-server
35+
zypper install --no-confirm --auto-agree-with-licenses --no-recommends mssql-server && \
36+
# add mssql-tools repo
37+
zypper addrepo --check https://packages.microsoft.com/config/sles/15/prod.repo && \
38+
zypper refresh packages-microsoft-com-prod && \
39+
# install mssql-tools (consider removing to reduce size) Microsoft already maintains a separate mssql-tools image
40+
ACCEPT_EULA=Y zypper install --no-confirm --no-recommends mssql-tools && \
41+
zypper clean --all && \
42+
# post installation of SQL Server the mssql user/group is created
43+
# so set the right permissions to the msssql folder
44+
mkdir -p -m 770 /var/opt/mssql && \
45+
chown -R mssql /var/opt/mssql && \
46+
# grant sql the permissions to connect to ports <1024 as a non-root user
47+
setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr && \
48+
# allow dumps from the non-root process
49+
setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper && \
50+
setcap 'cap_sys_ptrace+ep' /usr/bin/gdb && \
51+
# ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH
52+
# and other env variables that control dynamic linking
53+
mkdir -p /etc/ld.so.conf.d && \
54+
touch /etc/ld.so.conf.d/mssql.conf && \
55+
echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf && \
56+
ldconfig
57+
58+
EXPOSE 1433
59+
60+
USER mssql
61+
62+
CMD ["/opt/mssql/bin/sqlservr"]

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 SP3 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: 0 additions & 61 deletions
This file was deleted.

linux/preview/openSUSE/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM opensuse/leap:15.4
2+
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
9+
10+
# consider merging the two RUNs to save ~ 100mb at the cost of caching adding the signing key
11+
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
33+
34+
EXPOSE 1433
35+
36+
USER mssql
37+
38+
CMD ["/opt/mssql/bin/sqlservr"]

linux/preview/openSUSE/dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)