Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to enable overcommit memory in docker-entrypoint #298

Closed
Me-ion opened this issue Nov 17, 2021 · 5 comments
Closed

Add a way to enable overcommit memory in docker-entrypoint #298

Me-ion opened this issue Nov 17, 2021 · 5 comments

Comments

@Me-ion
Copy link

Me-ion commented Nov 17, 2021

From https://redis.io/topics/admin:

Make sure to set the Linux kernel overcommit memory setting to 1

Can we add something like following in the docker-entrypoint script to be run before the redis server is started

if [[ "$ENABLE_OVERCOMMIT_MEMORY" == 'true' ]]; then
	echo 1 > /proc/sys/vm/overcommit_memory
fi

then it would be really easy to enable that with:

docker run \
    -e ENABLE_OVERCOMMIT_MEMORY=true \
    ....

that would make it so much easier than creating a custom image and/or entrypoint script

@yosifkit
Copy link
Contributor

Related issues. #19, #20, #55; This value is not namespaced and so must be set on the host as the container cannot set it.

$ docker run -it --rm redis bash
root@deaa79bd3204:/# cat /proc/sys/vm/overcommit_memory 
0
root@deaa79bd3204:/# echo 1 > /proc/sys/vm/overcommit_memory 
bash: /proc/sys/vm/overcommit_memory: Read-only file system
root@deaa79bd3204:/# 

@tianon
Copy link
Contributor

tianon commented Nov 17, 2021

Another fun way to try and set this is via Docker's --sysctl flag which gives:

invalid argument "vm.overcommit_memory=1" for "--sysctl" flag: sysctl 'vm.overcommit_memory=1' is not whitelisted

@Adrian-Grimm
Copy link

Related issues. #19, #20, #55; This value is not namespaced and so must be set on the host as the container cannot set it.

$ docker run -it --rm redis bash
root@deaa79bd3204:/# cat /proc/sys/vm/overcommit_memory 
0
root@deaa79bd3204:/# echo 1 > /proc/sys/vm/overcommit_memory 
bash: /proc/sys/vm/overcommit_memory: Read-only file system
root@deaa79bd3204:/# 
echo "vm.overcommit_memory=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

cat /proc/sys/vm/overcommit_memory

@idan3

This comment was marked as resolved.

@tianon

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants