Docker image to run msql-cli
, a python3 CLI for Microsoft Server.
A couple of points:
-
The docker image must be launched as interactive and with pseudo-TTY (
-it
) -
The docker image has a welcome message that shows how to launch the CLI
-
The Linux user
sqladmin
is created as used as the user within the docker image -
The Makefile picks the
docker
version/tag from theDockerfile
-
The Makefile uses
podman
instead ofdocker
if installed to run seamlessly on Fedora 30+- One can overwrite the choice of container executable to use with environment variable
DOCKER
- One can overwrite the choice of container executable to use with environment variable
-
One can run
make print-version
to extract the version label, which equals to runninggrep '^LABEL version=' Dockerfile | awk -F\= '{print $2}' | tr -d '"'
python3-pip
: to usepip
to install the applicationmssql-cli
: the CLI applicationwget
to get the Microsoft.deb
file to install .NET packages
As for the .NET for Linux see: Install .NET on Ubuntu - .NET | Microsoft Docs
In order to build the docker image execute:
docker build -t "mssqlcli:0.1" -f Dockerfile-mssqlcli-ubuntu .
Or you could use the Makefile
where the version number is derived from the LABEL version=...
entry in the Dockerfile
:
make build
The Makefile
defaults to using podman
, if installed. One can force the use of docker
with:
DOCKER=docker make build
One can launch the mssqlcli
for the docker
image with:
docker run -it "mssqlcli:0.1"
Inside the container run the following command, assuming that 172.31.44.147
the DB host IP and admin
is the user name:
python3 -m mssqlcli.main -S 172.31.44.147 -U admin
Articles that contributed to the Dockerfile:
-
10 best practices for creating good docker images | artindustrial it
-
non-root user inside a Docker container - Gerard Braad's blog
-
linux - How to add users to Docker container? - Stack Overflow
-
How can I get a docker container to load text from /etc/motd - Stack Overflow
-
How to change welcome message (motd) on Ubuntu 18.04 server - LinuxConfig.org