7

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
Wei
  • 451
  • 1
  • 5
  • 15

1 Answers1

3

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

Thilak
  • 935
  • 8
  • 12
  • I am having this error in gitlab-ci runner when trying to use `expo` cli. Where should I add this command? at the docker gitlab ci runner level ? – Dimitri Kopriwa Dec 29 '19 at 21:17
  • @DimitriKopriwa Can you create a new thread with some detailed information (command used, error details, etc..)? So that it will help us analyze the issue. – Thilak Jan 02 '20 at 05:40
  • Docker does not support setting all sysctl values. See this link: https://docs.docker.com/engine/reference/commandline/run/#configure-namespaced-kernel-parameters-sysctls-at-runtime. Certain kernel parameters cannot be set within Docker containers. They need to be set on the host computer – Nadir Latif Oct 21 '20 at 11:32