Run container but exited immediately

Hi

I have centos 7 and installed the dockrer. docker version is 1.10.3 .

i have pul the centos image from the docker hub but when I run it will automatically exited . why it exited immediattely ???

[root@t1-dev-new ~]# docker run centos
[root@t1-dev-new ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@t1-dev-new ~]# docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f19e83f949c9 centos “/bin/bash” 14 seconds ago Exited (0) 14 seconds ago prickly_heisenberg
[root@t1-dev-new ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f19e83f949c9 centos “/bin/bash” 19 seconds ago Exited (0) 18 seconds ago prickly_heisenberg
8f99ee99d508 centos “/bin/bash” 16 hours ago Exited (0) 16 hours ago modest_lichterman
1419f6911ccd centos “/bin/bash” 16 hours ago Exited (0) 16 hours ago compassionate_panini
ba30af9817e9 nirajvara/centos-apache “/bin/bash” 16 hours ago Exited (0) 16 hours ago condescending_jepsen
[root@t1-dev-new ~]#
[root@t1-dev-new ~]# docker iamges
docker: ‘iamges’ is not a docker command.
See ‘docker --help’.
[root@t1-dev-new ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nirajvara/centos-apache latest 91936de205a9 46 hours ago 316.7 MB
docker.io/centos latest 50dae1ee8677 2 days ago 196.7 MB

common centos dokcer image as well as any other basic os images do not contain cmd command (do not run any default app)

if you need to run interactive bash shell in default container type:
docker run -t -i centos /bin/bash
and you get into container with /bin/bash

Hi

If I run this command

docker run centos ---- then centos container should be start or not ???

it should show during this command ???

docker ps

Its not showing up that is the issue.

this command perform container run in interactive mode with running /bin/bash as a command

HI

Yes I got it.

But I dont want right now to run container in interactive mode.

I want to just start container only.

you need to start from docker tutorials

anyway this is command you need :
docker run -d -t -i centos /bin/bash

my output for centos 7 image :

ubuntu@ubuntu:~$ docker run -d -t -i centos:7 /bin/bash
6a82a5488857472740a7950bc6eb1b0e7455fbd10ad30512f68c58cc4011d325
ubuntu@ubuntu:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a82a5488857 centos:7 “/bin/bash” 3 seconds ago Up 1 seconds focused_meninsky

1 Like

Hi

Thnks you very much for your help. now its done.

My misconcept was if I run this " docker run centos " IT will start the centos in backgroup but now got it.

Thanks @nickdoikov. I build one image which I could run using your suggested command
docker run -d -t -i myimage /bin/bash

but if I put CMD ["/opt"]
I get error:Error response from daemon: OCI runtime create failed: container_linux.go:296: starting container process caused “exec: “/opt/kaldi”: permission denied”: unknown.

Do you have any suggestions.

Thanks in advance.

Thanx nickdoikov.I was also facing same problem but i got answer