Docker Community Forums

Share and learn in the Docker community.

"Docker run" on already running containers


(Arpan941) #1

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?


(Sam) #2

no… docker run created another instance of the container from whatever image you used.

the original container is untouched.


(Arpan941) #3

But it didnt. I checked using docker ps. It only showed me the previously running conatiner up and running from hours. And when I checked inside the container, the value of somaxconn had changed. How did this happen?


(Mbloore) #4

try using ‘docker ps -a’. that will also show you containers that are stopped but still present. when you exit an interactive container that you did not run with the ‘–rm’ option, it is stopped but not removed. you can get into it again with ‘docker start HASH’ followed by ‘docker attach HASH’, where HASH is from the first column of the ps output.
you can attach to the container, set that variable, and run whatever needs it. or let it run on its own, however you’ve set things up.
your run command doesn’t show the ‘-it’ option, which makes the container interactive. it’s good to have that even though you are running bash in the container.