SQLGeordie's Blog

Helping the SQL Server community……where i can!

Merge image layers in Docker using –squash — June 20, 2018

Merge image layers in Docker using –squash

A question which always gets asked regarding the union layered filesystem for images is whether the intermediary image layers can be merged into one? The answer is yes, you can –squash image layers during a bulid from a Dockerfile.

The attached video shows 2 example builds of the same Dockerfile, one is standard, the second using –squash to merge the layers.

Merge image layers in Docker

Advertisements
Docker and SQL Server on Linux series —

Docker and SQL Server on Linux series

DockerBuildShipRunAnywhere

I’ve been playing around with Docker (more specifically with SQL Server on Linux) the beginning of 2017 to see if indeed I can “Build, Ship, Run, Any App Anywhere” and will be putting together a series of how-to’s and issues experienced so you guys don’t spend the countless hours trying to investigate and work out what is going on when things do not work.

I’ll be adding links to this main page as and when new posts are added as a central point of reference.

 

 

Docker for Windows -SwitchDaemon easily — May 3, 2018

Docker for Windows -SwitchDaemon easily

If you are using Docker for Windows and want to switch between Linux or Windows containers you can do this by right clicking the Docker “Whale” in the systray and selecting “Switch to Windows containers”:

Switch to Windows containers

….but no one likes clicking around do they!

There is an alternative way to do this which I use in my docker session demo’s which makes things so much easier and the switch is a lot quicker! In powershell, run the script below and it’ll switch from Linux to Windows containers and vice versa:

Linux Containers:

LinuxContainerDaemon

Run the SwitchDaemon script:

& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
Windows Containers:
WindowsContainerDaemon
and there you have it, a very simple but extremely useful snippet to switch between Linux and Windows containers,
Workaround for – The transaction log for database ‘master’ is full due to ‘NOTHING’ – Docker — April 24, 2018

Workaround for – The transaction log for database ‘master’ is full due to ‘NOTHING’ – Docker

As with anything open source you’re prone to things changing without you necessarily being aware and the error message in the blog title is something that has been sprung upon me whilst tidying up demo’s for my latest session on Docker and SQL Server On Linux. I hadn’t touched these particular demo’s since October 2017 so as to when things stopped working, I don’t know but they certainly worked the last time I did the session but doing a re-pull of the images, things broke.

With the micorosft/mssql-server-linux images, if you wish to mount a volume to a container then you will experience an error message I’ve never seen in SQL Server:

The transaction log for database ‘master’ is full due to ‘NOTHING’.

The transaction log for database 'master' is full due to 'NOTHING'

Apparently I’m not the only one experiencing this and there is an issue opened (Since October 2017!!!) on GitHub and social.msdn.microsoft.com describing the issue.

I have tested:

  • micorosft/mssql-server-linux:latest
  • micorosft/mssql-server-linux:2017-GA

and the issue was apparent on both images. The reason as highlighted on GitHub seems to be related to the filesystem, seeing as I’m running Docker for Windows I can’t change my file system from ext3 to ext4 like what others have done.

There is a workaround for this. The issue (certainly for me) only seems to be apparent if you try to mount a volume to a folder that already exists (ie. /var/opt/mssql/data/), mount to a new folder (ie. /sqlserver/data) then it will work:

Works:

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@ssword1' `
--cpus="2" `
--name SQLLinuxLocal1 -d -i `
-p 1433:1433 `
-v C:\Docker\SQLServer\Linux\SQLLinuxLocal:/sqlserver/data/ `
microsoft/mssql-server-linux:latest

Does not work:

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@ssword1' `
--cpus="2" `
--name SQLLinuxLocal2 -d -i `
-p 15106:1433 `
-v C:\Docker\SQLServer\Linux\SQLLinuxLocal:/var/opt/mssql/data/ `
microsoft/mssql-server-linux:latest

Or if you can, create a data volume instead and use that 😉

Once you have the files you need (ie. .bak file) in the /sqlserver/data folder within the container, you can then restore it using WITH MOVE to the /var/opt/mssql/data/ folder and this will work.

Introduction to Docker – Slides and Demo’s —
Docker – SQL on Linux image tag has changed! — October 4, 2017

Docker – SQL on Linux image tag has changed!

With the announcement of SQL Server 2017 last week came the updated microsoft/mssql-server-linux and microsoft/mssql-server-windows* docker images.

By default if you do a docker pull without a tag you will pull down the latest however with these new docker images this no longer works:

Docker pull latest.png

You get the error:

Error response from daemon: manifest for microsoft/mssql-server-linux:latest not found

I found this a bit strange so went onto the docker hub searching for microsoft/mssql images and see if they actually did exist:

Docker images on msft repo.PNG

SQL on Linux is what I was after and you can see from the image above it does exist but taking a close look at the tags tab you can see that they have now amended the tags to be microsoft/mssql-server-linux:2017-GA and microsoft/mssql-server-linux:2017-latest.

SQLonLinux-tags
The new tags

 

SQLonLinux-tags 2
This kind of tells us things have changed!

 

NOTE: The windows docker images still have the “latest” tag available

SQLonWIndows-tags

Now, if we run docker pull with the 2017-GA or 2017-latest tag it will grab it:

docker pull microsoft/mssql-server-linux:2017-GA

Docker pull 2017-GA.png

Obviously I have already done this and the image is up to date 🙂

 

Time to update all my demo scripts 😦

Docker and SQL Server – Useful links — July 23, 2017

Docker and SQL Server – Useful links

Docker

Below are a collection of links I’ve used as reference throughout my journey of Docker and running SQL Server containers. These have been invaluable in knowledge gathering and troubleshooting throughout this (at times) painstaking process.

First and foremost I would like to put a huge shout out to Andrew Pruski (b|t) for his Container Series which if you haven’t had a look at then I suggest you do, like now! He has put together some great content for anyone looking to get started with Containers.

I have tried to section them to make things easier to refer to and more than happy for others to suggest others to add:

Getting Started with Docker:

Tutorials

SQL Server on Linux:

Use cases:

General:

Licensing:

Installing:

Setup on Windows 10 VM:

SQL Server On Linux:

Connecting to SQL Server via sqlcmd:

Legacy SQL Server Containers

Performance

Issues and Troubleshooting

Using Volumes

Hyper-V containers