ocker run --name mongo-container --cpus="16" --memory="32g" -p 27017:27017 -v aprivolume:/data/db -v /srv/mongodb/mongod.conf:/etc/mongod.conf -e MONGO_INITDB_ROOT_USERNAME=aaa -e MONGO_INITDB_ROOT_PASSWORD=bbb -d mongo WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap. be1de843c7ca4319796955913d9299c47b76b195d977538bc648e74a4331574e
The command you provided is used to run a MongoDB container using Docker with specific resource limits and configurations. Let's break down the command and the warning message you received:
docker run
: This command is used to create and start a new container.--name mongo-container
: This option names the container "mongo-container".--cpus="16"
: This limits the container to use a maximum of 16 CPU cores.--memory="32g"
: This limits the container to use a maximum of 32 GB of RAM.-p 27017:27017
: This maps port 27017 of the container to port 27017 on the host, allowing access to MongoDB.-v aprivolume:/data/db
: This mounts a Docker volume named aprivolume
to the container's /data/db
directory, which is where MongoDB stores its data.-v /srv/mongodb/mongod.conf:/etc/mongod.conf
: This mounts a configuration file from the host at /srv/mongodb/mongod.conf
to the container's /etc/mongod.conf
.-e MONGO_INITDB_ROOT_USERNAME=aaa
: This sets an environment variable to initialize the MongoDB root username to "aaa".-e MONGO_INITDB_ROOT_PASSWORD=bbb
: This sets an environment variable to initialize the MongoDB root password to "bbb".-d mongo
: This runs the container in detached mode using the official MongoDB image.The warning message you received is:
WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
This warning indicates that your Docker installation is unable to enforce memory limits with swap due to one of the following reasons:
Kernel Support: Your Linux kernel may not support memory swap limits. This is often the case with older kernels or certain distributions that do not have the necessary configurations enabled.
Cgroup Configuration: The control groups (cgroups) may not be properly mounted. Cgroups are a Linux kernel feature that allows you to allocate resources (like CPU and memory) to processes.
To resolve this warning, you can try the following:
Check Kernel Version: Ensure that you are using a recent version of the Linux kernel that supports cgroup memory limits. You can check your kernel version with:
uname -r
Enable Cgroup Memory: If you are using a systemd-based distribution, you can enable cgroup memory by editing the GRUB configuration:
/etc/default/grub
and find the line starting with GRUB_CMDLINE_LINUX_DEFAULT
.cgroup_enable=memory
and swapaccount=1
to the line.sudo update-grub
Use a Different Docker Storage Driver: Sometimes, the storage driver can affect cgroup functionality. You can check your current storage driver with:
docker info | grep "Storage Driver"
Consult Documentation: Refer to the Docker documentation for your specific operating system for more detailed instructions on enabling memory limits.
After making the necessary changes, you can try running your MongoDB container again to see