microsoft / mssql-docker

Official Microsoft repository for SQL Server in Docker resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Out of memory

eSPiYa opened this issue · comments

commented

I'm trying to move our development environment to docker and I'm having issue during migration and data seeding where our scripts inserting massive amount of data. It takes at least 5min from empty database to complete the migration if it is using the SQL Server Developer Edition installed on my workstation, but the whole operation actually not taking too much resources, so I believe that 8G that I put in my docker-compose file below is excessive already , I believe 4GB is more than enough, but it still saying out of memory.

version: '3.9'

services:  
  sqlserver:
    image: mcr.microsoft.com/mssql/server:2022-latest
    ports:
      - "1434:1433"
    environment:
      MSSQL_PID: Developer
      MSSQL_SA_PASSWORD: <strong password>
      ACCEPT_EULA: Y
      MSSQL_TCP_PORT: 1433
    volumes:
      - sqlserver-data:/var/opt/mssql
    deploy:
      resources:
        limits:
          cpus: "4"
          memory: 12G
        reservations:
          cpus: "2"
          memory: 8G

volumes:
  sqlserver-data:

When I check sys.dm_os_sys_info, it can detect the exact number of CPUs my physical machine have, and not the one I put in the limits or reservations. Although I'm fine for it to use all the available CPUs in my machine, it seems like those are not working. physical_memory_kb returns 1616896, or around 1.5GB only.

Then I checked the Docker container hosting the SQL Server, but it looks like it is using the memory limits, I got 12884901888:
docker inspect --format='{{.HostConfig.Memory}}' <container_name>

I checked the SQL Server running on my desktop and it reflected the correct number of CPUs and the physical_memory_kb 16641840 or less than 16GB. I believe this is correct because this laptop has 16GB RAM installed.

So, how can I make SQL Server maximize the resources provided to its container? Or set how much memory it should use.