Search code examples
linuxbashdockerdebiandebian-stretch

"bash: sysctl: command not found" in debian:stretch-slim


when I pull the debian:stretch-slim from hub.docker.com, and then run a container(root), I find that bash: sysctl: command not found.

How can I use sysctl in debian:stretch-slim?

and many images are builded from debian:stretch-slim, so when I want to use sysctl in some other containers like that:

docker run --rm -it redis:latest --sysctl net.core.somaxconn=2048 redis-server

It will throw ERROR message.

It can be tested like:

docker pull debian:stretch-slim
docker run --rm -it debian:stretch-slim bash
root@7b923f27f7ee:/# sysctl
bash: sysctl: command not found

Solution

  • Start your container with this command:

    docker run --rm -it --sysctl net.core.somaxconn=2048 redis:latest redis-server

    --sysctl should be docker run's argument and it should not be a command to your redis image