Don Chambers
Don Chambers

Reputation: 4289

Docker SQL Server image getting large with each docker commit

I have a docker SQL Server image that I configure and then share with team. Each time I update the data the image size increases significantly.

I start with the mcr.microsoft.com/mssql/server:2019-latest image which is about 1.6 gigs. I have to do a custom setup, such as adding a MasterKey, a LinkedServer, and some logins. Then I restore backups of my databases and commit the container to create a new image. This image is about 6.5G. That's understandable because I have added my data. I push this image to the registry for the rest of our team to use.

Later, I refresh the data to keep the image updated. To do this, I drop the databases, restore from new backups, and commit the container. The size of my data only slightly increased, but the size of my image is now 13G (about double the last image).

Today I noticed a problem with a linked server definition. I fixed it, and committed the container. There was no data changed but now the image is over 20G.

Because of the custom configuration at the beginning, I don't want to start over with the default image each time. Also, I may only restore one database and leave others the same.

What is causing this?

Does each commit include the previous image as a layer, which is essentially doubling the size of the image?

Any tips of how to make this image smaller.

Upvotes: 0

Views: 685

Answers (0)

Related Questions