Home > Workload Solutions > SQL Server > White Papers > SQL Server 2019 Containers on Linux > Memory
You can allocate memory to a container in either of two ways. The first is the –m or −−memory flag that specifies the maximum amount of memory that the container can use. For example, the minimum amount of required memory for the SQL Server image is 2 GB of RAM. Because databases benefit from more memory, we used 16 GB, as shown in the following command:
$ docker run –cpus=”2” –-memory=16g --name sqlservername -e “ACCEPT_EULA” -e “MSSQL_SA_PASSWORD=password” -v volumename:/var/opt/mssql-data-dir -p 1433:1433 -d localhost:5000/sql2019
The second way to configure memory is by using the –memory-reservation flag. With this flag, you can specify a soft limit that is smaller than the –-memory configuration, as shown in the following command. If Docker detects memory contention on the server, the setting on the –memory-reservation flag specifies the minimum amount of memory for the container.
$ docker run –cpus=”2” –-memory=16g –memory-reservation=4g --name sqlservername -e “ACCEPT_EULA” -e “MSSQL_SA_PASSWORD=password” -v volumename:/var/opt/mssql-data-dir -p 1433:1433 -d localhost:5000/sql2019
By using the –-memory and –memory-reservation flags, you can enforce hard memory limits to prevent out-of-memory conditions on the server.