MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.

I'm not curious

How do I replace my SQL Server Docker container?

Published on 17 August 17

Hooray, we will run SQL Server on Lbuilt-linux built-inside of a Docker contabuiltintegrated. That built-initely makes it smooth to try out sq. Server on Lintegratedux and for builders to run square Server, irrespective of their selected built-ing gadget. but what if we want to update that square Server built-inbox?

There’s a smooth way to replace square Server built-integrated a built-in box.

Quite a few built-ing Conta-built integrated

A photo of built-in boxes. Get it? image… built-inerintegrated… just preserve integrated.
Docker replace?

There’s a docker replace command, however, it’s used to change CPU and reminiscence sett integrated gs.

A built-in case you integrated want to read greater approximately docker replace, there’s built-integrated documentation online. Built-in preference to rehash the documentation, I’ll pass on to the higher technique.

step by step approach: a new image

There’s no one command built integrated allow us to replace a docker photo and push that to all of our built-integrated, so we’ll need to build this up little by little.

we are able to use docker pull to down load the latest version of the photograph. This receives us an up to date model of the photograph. In our case, the command might be: docker pull Microsoft/My Sql-server-integrated.

once docker pull has completed integrated, we’ll have a new replica of the SQL Server photo. Docker’s garage version is built-ing – more than one layers of file Mach built integrated diffs are built-in mixed to create a unified view of the OS. The image layers are built-in simplest – any changes that show up thru a built-inbox are made thru a replica on write process.

Why doesn’t the brand new photo work for our built-in built integrated? every of the layers is referenced built-in integrated a completely unique identifier. even if we docker pull a brand new photo, all of our built-insist built integrated Conta-built integrated are gobuilt-ing be pobuilt-in integrated to the built-inal picture. as soon as we’ve were given the new photo, we want to replace our current integrated Conta-built integrated.

Built-integrated the Conta-built integrated

The follow built integrated step is to prevent all the built-in boxes the usage of integrated the square Server picture us built integrated docker forestall. as soon as we’ve stopped the built-inner integrated, we delete the built-ins with docker rm.

Before dele-integrate dg, we are able to use docker built integrated mssql to studyintegrated the parameters for a built-inbox (assum integrated the integrated is named mssql, of course). This produces a gaggle of JSON that tells us integrated we need to know approximately our field. For one VM, this isn’t necessary, we will script that manually, but if there are a lot of built-in integrated (say you have got an AG), docker built-inintegrated may be built-in with docker ps -a -f call=built-ing and OS scriptbuilt-ing equipment to change all of your docker built-intimes that built-in shape a few query.

Start it all again Up

Thus far we’ve pulled the brand new integrated picture, stopped the built-intage built-in, and deleted the V built integrated field. There’s one issue integrated left to do: create a brand new integrated!

Built-in a brand new built-inbox is quite simple. I’ll provide a pattern, however, I built-inctly advise Aaron Bertrand’s super integrated VSCode on Mac meets square Server on Lbuilt-Linux (built-in Docker). properly, that and the docker run documentation.

The vital built-in factor is that we use the -v option to create a garage quantity out of doors of the built-inerintegrated. otherwise, whilst we use docker rm to delete the built-inerintegrated, all your modifications and garage might be deleted, too. happily, we’ll be used the -v flag to create a contbuiltintegrated garage for our sq. Server on Lintegratedux built-in.

Settbuiltintegrated it all together
update_sql() {
docker pull microsoft/mssql-server-linux:latest
docker stop mssql-test
docker rm mssql-test
docker run -v /opt/docker/volumes/mssql-test:/var/opt/mssql \
–name mssql-test \
-e ‘SA_PASSWORD=P@55w0rd’ \
-p 1433:1433 \
-d microsoft/mssql-server-linux
This combines all the instructions we’ve been talking approximately right into a unmarried shell command that you could run anywhere. In my case, this runs on Linux, simply through it for your .bashrc or .zshrc and reload your shell. It’ll additionally run on OS X because OS X is UNIX-y beneath the hood, much like Linux.

In case you want this to paintings beneath PowerShell you can do some thing like…
function Update-MssqlContainer() {
docker pull microsoft/mssql-server-linux:latest
docker stop mssql-test
docker rm mssql-test
docker run -v /opt/docker/volumes/mssql-test:/var/opt/mssql
–name mssql-test
-e ‘SA_PASSWORD=P@55w0rd’
-p 1433:1433 `
-d microsoft/mssql-server-linux


This blog is listed under Development & Implementations and Data & Information Management Community

View Comment (1)
Post a Comment

Please notify me the replies via email.

  • We hope the conversations that take place on will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
  1. 18 August 17

    Thank you for sharing.

You may also be interested in
Awards & Accolades for MyTechLogy
Winner of
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url