-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This example is based on the SQL Server 2019 container image. At the time of this commit, SQL Server 2019 is in preview.
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
linux/preview/examples/mssql-server-linux-non-root/Dockerfile-2019
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Exmple of creating a SQL Server 2019 container image that will run as a user 'mssql' instead of root | ||
# This is example is based on the official image from Microsoft and effectively changes the user that SQL Server runs as | ||
# and allows for dumps to generate as a non-root user | ||
|
||
|
||
FROM mcr.microsoft.com/mssql/server:2019-latest | ||
|
||
# Create non-root user and update permissions | ||
# | ||
RUN useradd -M -s /bin/bash -u 10001 -g 0 mssql | ||
RUN mkdir -p -m 770 /var/opt/mssql && chgrp -R 0 /var/opt/mssql | ||
|
||
# Grant sql the permissions to connect to ports <1024 as a non-root user | ||
# | ||
RUN setcap 'cap_net_bind_service+ep' /opt/mssql/bin/sqlservr | ||
|
||
# Allow dumps from the non-root process | ||
# | ||
RUN setcap 'cap_sys_ptrace+ep' /opt/mssql/bin/paldumper | ||
RUN setcap 'cap_sys_ptrace+ep' /usr/bin/gdb | ||
|
||
# Add an ldconfig file because setcap causes the os to remove LD_LIBRARY_PATH | ||
# and other env variables that control dynamic linking | ||
# | ||
RUN mkdir -p /etc/ld.so.conf.d && touch /etc/ld.so.conf.d/mssql.conf | ||
RUN echo -e "# mssql libs\n/opt/mssql/lib" >> /etc/ld.so.conf.d/mssql.conf | ||
RUN ldconfig | ||
|
||
USER mssql | ||
CMD ["/opt/mssql/bin/sqlservr"] |