How to run docker-based mssql-tools using a regular way

6.4k views Asked by At

I have installed a mssql server using docker microsoft/mssql-server-linux. It behaves the same as a regular mssql server. i.e my client can access it exactly the same way they access a regular mssql server.

Now I am installing mssql-tools using docker: mcr.microsoft.com/mssql-tools

Looks like in order to use the mssql-tools to access a mssql server (they want sqlcmd/bcp), my client has to run

docker run -it mcr.microsoft.com/mssql-tools

and then run

sqlcmd -S 127.0.0.1 -U sa” 

under a new interface

root@1396d2e50672:

It is not convenient because he has to change all the code where sqlcmd/bcp has been directly called to access the mssql server.

Is it how a container based mssql-tools works? How can I install a mssql-tool container without having the clients change their API?

1

There are 1 answers

1
KeepCalmAndCarryOn On

How do you want to run it?

There are multiple strategies here This refers to the server but that contains the tools as well

What I usually do is pass in an entrypoint change the workdir to a volume mount and mount a volume of scripts.

docker run \
    --entrypoint /opt/mssql-tools/bin/sqlcmd \
    -w /mymount  -v ./myscripts:/mymount \
  mcr.microsoft.com/mssql-tools \
    -S 127.0.0.1 -U sa -i myscriptinmymount.sql

Note the options to sqlcmd are passed as usual after the image

untested...