Suppose I ran
docker run Ubuntu
Now this will be executed but when i list containers it will be in exited state.
To restart container i use
docker start
Here while restarting container i am trying to pass the command sleep 20 but its not working.
I also tried using docker exec containerId sleep 5 but its showing me that the container is not running.
Is there a possible solution for this. Please help and explain.
Regards.
The container only stays alive while it has something to do.
If you tell it to sleep 5, then it will stay up for 5 seconds, then exit.
That’s correct and i know but i just wanted to know if its possible to assign a process or task with docker Start command. Like how we do with docker run ubuntu sleep 5.
I tried it and i wasn’t successful, maybe i am doing something wrong. Please Review.
Thanks
No. It will run only the command it got from docker run
or if the image already has a command from an ENTRYPOINT
in is dockerfile. You cannot give it a different command