1
votes

I am trying to change the value of somaxconn in a running docker container. I am using this command:

docker run --net=container:redis --sysctl net.core.somaxconn=65535 bash

I have checked that this command changes the value of somaxconn from 128 to 65535 in the running docker container.

Because docker run command creates and starts a new container, so, does this command recreates and starts my existing conatiner? Does it restart my running container with the somaxconn changes or does it change the value in the running docker docker container?

But one thing I would like to add is that after running the above command, the value of somaxconn was changed and when I did docker ps, it showed that the same container was up and running from long time ago, so, does that mean it changed the value in an already running container?

2

2 Answers

1
votes

docker run will always start a new container. If you already have a container running, it will not be affected by the docker run command.

You could look at the docker exec command. This allows you to execute a command in an existing container. However, this will not allow you to change the parameters with which the original container was started (e.g. changing the --sysctl param). To change these kind of parameters you must remove and recreate the container with the desired parameters.

See the docs for docker run and docker exec here: https://docs.docker.com/engine/reference/commandline/run/ https://docs.docker.com/engine/reference/commandline/exec/

1
votes

docker run command will always create a new container.

So you can do one thing. Execute following commands to change value in running container.

#>docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED                 STATUS              PORTS                     NAMES
80eb3dc8438b        abcxyz               "docker-entrypoint.sâ¦"   22 hours     ago      Up 22 hours                     abcxyzfriendlyname

Look for container-name or id (e.g. 80eb3dc8438b) Then launch the following command : (Make sure your container is running at this moment).

#>docker exec 80eb3dc8438b   sysctl net.core.somaxconn=65535

I am not sure whether it will persist data in the container or is it just available in session only.