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
sqladminis created as used as the user within the docker image -
The Makefile picks the
dockerversion/tag from theDockerfile -
The Makefile uses
podmaninstead ofdockerif 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-versionto extract the version label, which equals to runninggrep '^LABEL version=' Dockerfile | awk -F\= '{print $2}' | tr -d '"'
python3-pip: to usepipto install the applicationmssql-cli: the CLI applicationwgetto get the Microsoft.debfile 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 buildThe Makefile defaults to using podman, if installed. One can force the use of docker with:
DOCKER=docker make buildOne 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 adminArticles 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