
Now we can execute commands in this shell. Once centos container started, it executed /bin/bash by default and -it flag forced it to keep stdin open and assign a interactive terminal for us. Let’s run a centos container and keep it’s shell open in interactive mode i.e.

Override default command while running a Docker container We can override this default command and make container to run another process on start. So, when we created and ran the container, it started and executed command /bin/bash and exited soon after that.


Like in case of centos image has default command is “/bin/bash”. Why did that happen ?īecause when we don’t provide any while running a container in docker run command then it runs the default command set in the image. It shows that container with ID “f497edf4ba16” started from centos image but its status is Exited i.e. We can confirm this by following commandĬONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESį497edf4ba16 centos "/bin/bash" 4 seconds ago Exited (0) 3 seconds ago admiring_hertz Well our container started and stopped instantly. If not then it will first fetch the centos image from repository and then start the container.īut, we got our prompt back, Is container running now ? It will first check if the docker engine has centos image or not. We can create and run a container using docker run command.
