I have used run command in docker cli to so when i used the command
docker run --name ubuntu ubuntu
it simply exists because it has no ptty and input output connection and we can attach our terminal using -it flags but when we try to start docke container which is in stopped state why does the container by default start in dettached mode this behaviour has not even been mentioned in documentation.
when i use the command
docker start ubuntu
when container "ubuntu" is in stopped mode the container is up and is running in background but when i use "docker run" command the container simply stops can someone explain this behaviour.
and it would be great if you can provide some material to refer as i found none regarding this behaviour.
by running
docker container ls -ayou can see your stopped containers and the
PID 1orEntryPointof the container in COMMAND column.which is
/bin/bash.that's it , and because you did not attach to the shell , it is exited
it is immediately done and the container is exited , so the status column shows "Exited (0)".
the number inside the parentheses is the Exit code for the container.
if you start the container again i don't think there would be a difference.
you can give a command to overwrite the main
EntryPointfor the image which is just/bin/bashor attach to it with-itwhile running the container for the first time.suggestion:
It will run the container indefinitely until you stop it
Hope that helps!