microsoft / mssql-docker

Official Microsoft repository for SQL Server in Docker resources
MIT License
1.73k stars 756 forks source link

Docker for Windows mssql-server-linux:latest fails to run due to memory limit #293

Open wsmelton opened 6 years ago

wsmelton commented 6 years ago

I may be doing this wrong...

Docker: 18.04.0-ce-win62 (17151) image: microsoft/mssql-server-linux:latest

I'm just trying to run the following:

docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=supersecret" -p 1417:1433 --name sql17 --platform linux -d microsoft/mssql-server-linux:latest

I can see the container in VS Code created and started, but then immediately stops. I check the logs:

docker logs sql17 --tail 50 -f
sqlservr: This program requires a machine with at least 2000 megabytes of memory.

So I saw mention in another issue about -e "MSSQL_MEMORY_LIMIT_MB=3072" so I tried that but still gets the same error.

Am I doing something wrong?

twright-msft commented 6 years ago

if you are literally using supersecret as your password it isnt meeting complexity requirements. You can run it without -d to see the output and see if there is anything useful there.

wsmelton commented 6 years ago

Oh, you twisted my arm...I'll release my super secret password...but all the output I get is the same.

image

wsmelton commented 6 years ago

I'm pulling down the Ubunut:latest image to just see if I can get it to run. It may be just an issue with trying to run Linux over Windows mode...

twright-msft commented 6 years ago

Ah ha! You are hitting this issue where Linux Containers on Windows (LCOW) is limited to max 2GB of memory. https://github.com/Microsoft/opengcs/issues/145

wsmelton commented 6 years ago

I wonder why the that image is an issue because this works with no issue:

docker run -it --platform linux ubuntu:latest

image

twright-msft commented 6 years ago

The vanilla ubuntu VM can probably easily run with less than 2GB of RAM. SQL Server requires 2 GB+ of RAM. The error message you see there comes from sqlservr. It's a resource prerequisite check we do on start up of the sqlservr process.

georgedorn commented 6 years ago

I've read that there are options to reduce the memory usage of SQL Server. Is there a way to set those via the docker env file?

twright-msft commented 6 years ago

You can control the amount of memory that SQL Server uses by passing the MSSQL_MEMORY_LIMIT_MB environment variable. SQL Server on Linux does need a minimum of 2GB of memory though for now.

twright-msft commented 6 years ago

Looks like the option to configure the VM memory is back in the more recent versions of Docker for Windows. Can you please try changing this from the default 2 GB to 4 GB or something and try running SQL Server on Linux again? Should work now. image

wsmelton commented 6 years ago

Those options are not available under Windows Mode. I'm using the platform option to run a Linux container under Windows Mode.

eric-davis commented 6 years ago

I'm running into the same extremely annoying issue.

alexandrupascanu commented 6 years ago

Hello, I am facing the same issue using the latest docker version( 18.09.0-ce-beta1), i can;t start sqlsrv linux contaner: "sqlservr: This program requires a machine with at least 2000 megabytes of memory." I don't what to to fix it!.Can you help me out with this one,please? Thank you!

tomasfejfar commented 5 years ago

The 2GB minimum does not seem sensible to me.

Does really empty sqlsrv needs that much memory just to start? I understand there may be some (potentially big) performance degradation for bigger tables and bigger indices, but it does not seem sensible to beef up the machine just to create a table with 20 rows for Travis build. Production (!) and fast enough MySQL/MariaDB for small web can run on 512M DigitalOcean droplet along with httpd and standard Debian.

twright-msft commented 5 years ago

@tomasfejfar There's a bit more to it than just simply running SQL Server. Keep in mind that SQL Server on Linux runs inside of a platform abstraction layer (PAL). More detailed reading. The additional memory required to run the PAL itself is a big part of the overall memory demands of running SQL Server in as small of a footprint as possible. On a production system with 1 TB of RAM available the extra 512MB-1 GB to run the PAL is negligible, but when you are trying to run some CI tests on as small of a footprint as possible, it's completely understandable to want to minimize the memory consumption. We're working on reducing the memory footprint, but it will take some time. Hope that provides a bit more context.

tomasfejfar commented 5 years ago

That's much more context, thanks. And the link provided me with much deeper understanding. My understanding was pretty much limited to "it's probably just C, so not much different from other RDBMS".

beaudryj commented 5 years ago

Any Status update on this?

patoJamriska commented 5 years ago

Bumping this to see if anyone has looked into it or if there is a roadmap to support this eventually again.

beaudryj commented 5 years ago

Bumping this to see if anyone has looked into it or if there is a roadmap to support this eventually again.

banerjeeamit commented 5 years ago

We don't have anything to share at the moment. We are actively investigating how we can support this in production. Once we have support for the same, we will make a formal announcement and also update this thread.

Fatlonder commented 5 years ago

I have the following environment within my windows 10: Client: Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24302 Built: Fri Mar 23 08:31:36 2018 OS/Arch: windows/amd64 Experimental: false Orchestrator: swarm

Server: Docker Engine - Community Engine: Version: 18.09.1 API version: 1.39 (minimum version 1.12) Go version: go1.10.6 Git commit: 4c52b90 Built: Wed Jan 9 19:41:57 2019 OS/Arch: linux/amd64 Experimental: false

Before running the following command: docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=password' -p 1401:1433 microsoft/mssql-server-linux

I have set the limit on virtualbox for base memory to 2048 mb and it works properly

beaudryj commented 5 years ago

Not using vbox, using hyper-v default docker machine and will not be able to setup or push for vbox every where On Mon, Feb 11, 2019 at 2:02 PM Fatlonder notifications@github.com wrote:

I have the following environment withing my windows 10: **Client: Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24302 Built: Fri Mar 23 08:31:36 2018 OS/Arch: windows/amd64 Experimental: false Orchestrator: swarm

Server: Docker Engine - Community Engine: Version: 18.09.1 API version: 1.39 (minimum version 1.12) Go version: go1.10.6 Git commit: 4c52b90 Built: Wed Jan 9 19:41:57 2019 OS/Arch: linux/amd64 Experimental: false**

Before running the following command: docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=password' -e 'MSSQL_MEMORY_LIMIT_MB = 4000m' -p 1401:1433 microsoft/mssql-server-linux

I have set the limit on virtualbox for base memory to 2048 mb and it works properly

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/mssql-docker/issues/293#issuecomment-462451734, or mute the thread https://github.com/notifications/unsubscribe-auth/ACgvXOQntV2dSj_ocMPh-XcXVOTSVWk3ks5vMb5CgaJpZM4TeDRZ .

Fatlonder commented 5 years ago

Not using vbox, using hyper-v default docker machine and will not be able to setup or push for vbox every where On Mon, Feb 11, 2019 at 2:02 PM Fatlonder @.*> wrote: I have the following environment withing my windows 10: Client: Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24302 Built: Fri Mar 23 08:31:36 2018 OS/Arch: windows/amd64 Experimental: false Orchestrator: swarm Server: Docker Engine - Community Engine: Version: 18.09.1 API version: 1.39 (minimum version 1.12) Go version: go1.10.6 Git commit: 4c52b90 Built: Wed Jan 9 19:41:57 2019 OS/Arch: linux/amd64 Experimental: false* Before running the following command: docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=password' -e 'MSSQL_MEMORY_LIMIT_MB = 4000m' -p 1401:1433 microsoft/mssql-server-linux* I have set the limit on virtualbox for base memory to 2048 mb and it works properly — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#293 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ACgvXOQntV2dSj_ocMPh-XcXVOTSVWk3ks5vMb5CgaJpZM4TeDRZ .

Can't you change the memory limit on hyper-v as well? I guess there should be an option

beaudryj commented 5 years ago

You have to change them using docker flags with Linux containers but when you are using mixed mode containers I.e. windows containers along side Linux containers

Docker throws an error saying that memory resource allocation is not supported On Fri, Feb 15, 2019 at 4:27 PM Fatlonder notifications@github.com wrote:

Not using vbox, using hyper-v default docker machine and will not be able to setup or push for vbox every where … <#m-636101805999469629> On Mon, Feb 11, 2019 at 2:02 PM Fatlonder @.**> wrote: I have the following environment withing my windows 10: Client: Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24302 Built: Fri Mar 23 08:31:36 2018 OS/Arch: windows/amd64 Experimental: false Orchestrator: swarm Server: Docker Engine - Community Engine: Version: 18.09.1 API version: 1.39 (minimum version 1.12) Go version: go1.10.6 Git commit: 4c52b90 Built: Wed Jan 9 19:41:57 2019 OS/Arch: linux/amd64 Experimental: false Before running the following command: docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=password' -e 'MSSQL_MEMORY_LIMIT_MB = 4000m' -p 1401:1433 microsoft/mssql-server-linux* I have set the limit on virtualbox for base memory to 2048 mb and it works properly — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#293 (comment) https://github.com/Microsoft/mssql-docker/issues/293#issuecomment-462451734>, or mute the thread https://github.com/notifications/unsubscribe-auth/ACgvXOQntV2dSj_ocMPh-XcXVOTSVWk3ks5vMb5CgaJpZM4TeDRZ .

Can't you change the memory limit on hyper-v as well? I guess there should be an option

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/mssql-docker/issues/293#issuecomment-464206740, or mute the thread https://github.com/notifications/unsubscribe-auth/ACgvXHB9OKTivoryK7NMrFc3obfqIhKgks5vNyZTgaJpZM4TeDRZ .

jpiquot commented 5 years ago

Hi,

Any updates on this issue with Windows mixed containers?

simonpinn commented 5 years ago

👍 on not working in mixed mode Windows containers, no (apparent) way of increasing the Docker VM memory

beaudryj commented 5 years ago

Got tired of waiting and refocused effort in getting kubernetes cluster in azure working :/ On Fri, Mar 22, 2019 at 12:41 AM Simon notifications@github.com wrote:

+1 on not working in mixed mode Windows containers, no (apparent) way of increasing the Docker VM memory

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/mssql-docker/issues/293#issuecomment-475491989, or mute the thread https://github.com/notifications/unsubscribe-auth/ACgvXKsR8B8bhUR0JsXq5ZnxbbaaMDzJks5vZF7-gaJpZM4TeDRZ .

justin2004 commented 5 years ago

@wsmelton

I made a docker image that works around this memory (limitation) policy: https://github.com/justin2004/mssql_server_tiny

dnzhnshn commented 5 years ago

ı waste lots of time about this issue and ı couldnt find any solution. maybe @justin2004 ' image can solve this problem .. Does anyone try this ?

dougloyo commented 5 years ago

I had the same issue. Here is what I did to solve it:

  1. In the Windows Docker app right click and switch to Linux container image

  2. Open Settings and select Advanced (make it 3g) image

  3. then just run in bash or powershell: docker run --name demoSQLServer \ -p 1431:1433 \ -e "ACCEPT_EULA=Y" \ -e "SA_PASSWORD=1qaz.@WSX" \ -d microsoft/mssql-server-linux:latest

patoJamriska commented 5 years ago

@justin2004 I just came back to see if there was any status changes on this since my post last year and I see your branch as a viable Option. Again a lot of people do not realize that the issue is when they are trying to run mixed containers (linux containers running in windows mode with LCOW). Anyways, Justin I am going to pull your branch and see if I can implement your solution as one viable way to get it running in a container in linux running in mixed mode for windows

jsandquist commented 5 years ago

FWIW, the --memory option now works in my environment:

docker run --memory=2G -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=P@ssword12345' -p 1433:1433 mcr.microsoft.com/mssql/server

My environment:

PS C:\> [System.Environment]::OSVersion                                                                                                                                                                                                                                              
Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18362.0 Microsoft Windows NT 10.0.18362.0

PS C:\> docker version                                                                                                                                                                                                                                                               Client: Docker Engine - Enterprise
 Version:           19.03.0
 API version:       1.40
 Go version:        go1.12.5
 Git commit:        7c57940
 Built:             Wed Jun 12 09:43:47 2019
 OS/Arch:           windows/amd64
 Experimental:      true

Server: Docker Engine - Enterprise
 Engine:
  Version:          19.03.0
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.12.5
  Git commit:       7c57940
  Built:            Wed Jun 12 09:57:40 2019
  OS/Arch:          windows/amd64
  Experimental:     true
PS C:\>                                  
ggirard07 commented 5 years ago

@jsandquist where did you get 19.03.0? Is it Edge channel?

jsandquist commented 5 years ago

@ggirard07 Not Edge channel - but a recent Enterprise Edition download from https://hub.docker.com/editions/community/docker-desktop-ent

I have not yet looked at the Community Edition.

skand888 commented 5 years ago

The current implementation does not allow mcr.microsoft.com/mssql/server to start on Azure machine that actually had 2 GiB RAM (sizes A1v1, B1ms, F1s, etc.) because the machine reports just 1949872k total memory.

The 2 GiB DigitalOcean VM reports 2041328k total memory, and the container starts with no issues.

It looks like by "2000 megabytes" Microsoft actually means 200,000,000 bytes, and if kernel happens to take more than 140 MB RAM (like it now does on Azure VMs) - SQL Server will not start.

justin2004 commented 5 years ago

@skand888

I've started sqlserver on a machine with just 512 MB of RAM using: https://github.com/justin2004/mssql_server_tiny

skand888 commented 5 years ago

@skand888

I've started sqlserver on a machine with just 512 MB of RAM using: https://github.com/justin2004/mssql_server_tiny

Yes, I've seen your solution above, but I am somewhat worried for possible consequences because it will allow it to start on a machine with any amount of RAM and behaviour might be unpredictable. But if no other solution is found - we will probably use a modification of your solutions.

BTW, I noticed that you use 1024l 1024l 1024l 2l, while 1000l 1000l 1000l 2l should probably be enough.

justin2004 commented 5 years ago

@skand888

behaviour might be unpredictable.

we already know what would happen if physical RAM was low enough -- i'm sure you'd see lots of page faulting and kswapd would be busy, and things would take longer and maybe even timeout by wallclock time, same as any other application. but that is the price we pay with diminishing physical RAM.

BTW, I noticed that you use 1024l 1024l 1024l 2l, while 1000l 1000l 1000l 2l should probably be enough.

probably. if you test it i'll accept your pull request.

skand888 commented 5 years ago

@justin2004

We decided to go with your elegant solution with a couple of small updates. I've created pull request. Thank you for the solution!

kiramishima commented 4 years ago

Any Status update on this?

LukeCarrier commented 4 years ago

Is this yet more evidence that Microsoft care only about the development experience of Windows users? Sadly a predictable part of working within this sphere.

tomasfejfar commented 4 years ago

@LukeCarrier I don't think that's fair. MS is doing a lot for Linux development. I can imagine that porting database engine that used many low level Windows functions to work with the Linux kernel reliably is no small feat.

LukeCarrier commented 4 years ago

When you spend every minute of your work day wrestling elements of the Microsoft ecosystem into playing nicely with the wider world your ability to empathise with the teams shipping releases with major regressions day after day wanes somewhat.

Everything is very much Windows-first. If Microsoft don't care about the experience for those of us outside of that niche, they should do one of two things:

  1. Open source the stack and let us fix these problems by ourselves; or
  2. Just leave. We have alternatives, and simply not having the inferior product on the table for middle management and executives to choose would enable us to get on with building our platforms.

Just look at how little regard there is for customers of this platform in this very GitHub repo. A similar disinterest and, at times, outright hostility, meets customers trying to get feedback into product groups via Azure too.

I'm sorry, but I don't buy that Microsoft is open enough to support these platforms.

totollygeek commented 4 years ago

So, we let this issue just fade into the nether without any solution or is it just me? 🤔 I am experiencing the same problem with latest WSL2 and Docker in mixed mode (Windows Containers with experimental setting). I tried setting the memory into .wslconfig file, but I still get that error. I guess it is a dead-end 🤷‍♂️

justin2004 commented 4 years ago

@totollygeek

there is a workaround here: https://github.com/justin2004/mssql_server_tiny

it works in linux distros. maybe it will work in WSL?

totollygeek commented 4 years ago

@justin2004 Well, I manage to workaround it, using deprecated functionality as the deploy tags in docker-compose.yaml and give 3GB of memory to the container. It works then, but it is kinda ugly I guess.

lemonierlima commented 3 years ago

I was with the same problem.

To fix it, execute:

docker-machine stop
docker-machine ls (get name)
docker-machine inspect <NAME>

take a look StorePath Go to StorePath and open config.json alter attribute "Memory" save docker-machine start if necessary, reboot your system

then execute the pull container again =)

YusufSina commented 3 years ago

Here is my solution.

I was getting this logs from container named sql1.

This container is running as user mssql.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
sqlservr: This program requires a machine with at least 2000 megabytes of memory.
/opt/mssql/bin/sqlservr: This program requires a machine with at least 2000 megabytes of memory.

After searching a lil bit. I changed my virtual machine's ram from virtual box gui. It was 1024mb. I changed it to 4096mb.

Now it works

dotupNET commented 3 years ago

With WSL2 modify .wslconfig file in your user folder and reboot

[wsl2] memory=4GB # Limits VM memory in WSL 2 up to 4 GB processors=2 # Makes the WSL 2 VM use two virtual processors

KerbalSpike commented 3 years ago

With WSL2 modify .wslconfig file in your user folder and reboot

[wsl2] memory=4GB # Limits VM memory in WSL 2 up to 4 GB processors=2 # Makes the WSL 2 VM use two virtual processors

@dotupNET This does not solve the problem for me, and I'm not sure how this is supposed to help? as far as I understand it, it puts an upper limit on memory usage for WSL. We would need a way to specify minimum memory allocation to WSL to solve the issue.

the strange thing for me is: if I run docker in linux container mode, the sql container runs just fine, but if I'm in windows mode and launch it with "--platform=linux" I run into the memory issue...

Paula2001 commented 9 months ago

if you are literally using supersecret as your password it isnt meeting complexity requirements. You can run it without -d to see the output and see if there is anything useful there.

He gave you a problem why you are giving him hard time about his password that's outrages