{"id":9009,"date":"2022-06-01T16:32:15","date_gmt":"2022-06-01T14:32:15","guid":{"rendered":"https:\/\/via-internet.de\/blog\/?p=9009"},"modified":"2022-06-02T08:24:24","modified_gmt":"2022-06-02T06:24:24","slug":"daily-running-microsoft-sql-server-in-docker","status":"publish","type":"post","link":"https:\/\/via-internet.de\/blog\/2022\/06\/01\/daily-running-microsoft-sql-server-in-docker\/","title":{"rendered":"Daily: Running Microsoft SQL-Server in Docker"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using Docker is an effortless way to launch and run an application\/server software without annoying installation hassles: <em>Just run the image and you&#8217;re done.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\" id=\"tw-target-text\">Even if it&#8217;s quite an uncomplicated way of looking at it, in many cases it works just like that.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, let&#8217;s start with using Microsoft SQL Server as a database backend. We will use a docker image from Microsoft. Look here to <a aria-label=\"find  (opens in a new tab)\" href=\"https:\/\/hub.docker.com\/_\/microsoft-mssql-server\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">find <\/a>out more.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker\trun                                       \\\n\t\t\t--name mssql-server       \\\n\t\t\t--memory 4294967296       \\\t\n\t\t\t-e \"ACCEPT_EULA=Y\"        \\\n\t\t\t-e \"SA_PASSWORD=secret\"   \\\n\t\t\t-p 1433:1433              \\\n\t\t\tmcr.microsoft.com\/mssql\/server:2019-latestles<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Error: program requires a machine with at least 2000 megabytes of memory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Start the docker container as described on the Docker Hub Page: <a href=\"https:\/\/hub.docker.com\/_\/microsoft-mssql-server\" class=\"ek-link\">How to use this Image <\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f docker run -e \"ACCEPT_EULA=Y\" -e \"SA_PASSWORD=secret\" -p 1433:1433 mcr.microsoft.com\/mssql\/server:2022-latest<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Depending on how your docker environment is configured, this could bring up an error:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"4-\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SQL Server 2019 will run as non-root by default.\nThis container is running as user mssql.\nTo learn more visit https:\/\/go.microsoft.com\/fwlink\/?linkid=2099216.\nsqlservr: This program requires a machine with at least 2000 megabytes of memory.\n\/opt\/mssql\/bin\/sqlservr: This program requires a machine with at least 2000 megabytes of memory.<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As the error message states, the MS SQL server needs at least 2g of RAM. So, you must assign your Docker VMs more memory. This is configured in the Docker Dashboard.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hint: Docker has two ways of running containers:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>using Windows Container<\/li><li>using WSL (Windows Subsystem for Linux)<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You can change the way with the context menu of the docker symbol in the task bar:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-switching-container-mode.png\" alt=\"\" class=\"wp-image-9013\" width=\"373\" height=\"416\" srcset=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-switching-container-mode.png 497w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-switching-container-mode-269x300.png 269w\" sizes=\"auto, (max-width: 373px) 100vw, 373px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">With Linux Containers (using WSL as backend), you must configure the containers via a file<code> .wslconfig<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This file is in the folder defined by the environment variable <code>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"296\" src=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-docker-config-1024x296.png\" alt=\"\" class=\"wp-image-9012\" srcset=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-docker-config-1024x296.png 1024w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-docker-config-300x87.png 300w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-docker-config-768x222.png 768w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-docker-config.png 1489w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To open the file, run the command:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>From Command Prompt<\/td><td><code>notepad \n\n\n\n<p class=\"wp-block-paragraph\">Edit the content and change the memory setting<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"yaml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[wsl2]\nmemory=3GB<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart WSL with the new settings.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f wsl --shutdown<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"462\" height=\"248\" src=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-restart-wsl2-backend.png\" alt=\"\" class=\"wp-image-9014\" srcset=\"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-restart-wsl2-backend.png 462w, https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/daily_running-microsoft-sql-server-in-docker-restart-wsl2-backend-300x161.png 300w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Start Container again, now everything should work<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f docker run -e \"ACCEPT_EULA=Y\" -e \"SA_PASSWORD=secret\" -p 1433:1433 mcr.microsoft.com\/mssql\/server:2022-latest<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Using Docker is an effortless way to launch and run an application\/server software without annoying installation hassles: Just run the image and you&#8217;re done. Even if it&#8217;s quite an uncomplicated way of looking at it, in many cases it works just like that. So, let&#8217;s start with using Microsoft SQL Server as a database backend. We will use a docker image from Microsoft. Look here to find out more. FAQ Error: program requires a machine with at least 2000 megabytes of memory Start the docker container as described on the Docker Hub Page: How to use this Image Depending on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9016,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[135,102],"tags":[133,134],"class_list":["post-9009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-daily","category-power-shell","tag-daily","tag-powershell"],"jetpack_featured_media_url":"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/Header-Daily-Running-Microsoft-SQL-Server-in-Docker.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/9009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/comments?post=9009"}],"version-history":[{"count":7,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/9009\/revisions"}],"predecessor-version":[{"id":9032,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/9009\/revisions\/9032"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media\/9016"}],"wp:attachment":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media?parent=9009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/categories?post=9009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/tags?post=9009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}