I have docker container with installed and configured software.
There is no any programm supposed to be started/runned all the time.
What I want – its ability to start some command depending on external events. like:
docker exec mysupercont /path/to/mycommand -bla -for
and
docker exec mysupercont /path/to/myothercommand
But "exec" impossible when container is stopped, and also this container have some "working" data inside, which used for that commands, so I can't use
docker run ...
each time, because it recreate container from image and destroy my data.
What is the "right" and the "best" way to keep such container runned?
Which command I can start inside?
Best Answer
You do not need to perform each time
docker run
.docker run
is actually a sequence of two commands: "create" and "start".When you run the container, you must specify the "
-it
":Example:
After the work was completed command specified at startup (in my example bash). For example, you perform the "exit". Container stops:
Now you can start it again
The container is started and again executes the command "bash".
Connect to this session "bash" with the command
To sum up: you have to understand the difference between the
run
andstart
container.Besides, look at the documentation for the role of parameters "
-i t
" and "-d
" for the "Run"