Docker Community Forums

Share and learn in the Docker community.

CentOS image is not running?

docker

(Bluemind2005) #1

Hi Friends,

I downloaded centos base image executed in background as daemon and then tired to get in the terminal and couldn’t get in.

My Host is Ubuntu 16.04.

Here are the steps I executed:

Host OS Version Ubuntu16.04

 root@jim-Ubuntu1504:/home/jim/web# lsb_release -a No LSB modules are
 available. Distributor ID: Ubuntu Description:    Ubuntu 16.04 LTS
 Release:        16.04 Codename:       xenial
 root@jim-Ubuntu1504:/home/jim/web#

Started docker by following commands

root@jim-Ubuntu1504:/home/jim/web# docker run -d --name=my_centos centos
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
a3ed95caeb02: Pull complete 
da71393503ec: Pull complete 
Digest: sha256:1a62cd7c773dd5c6cf08e2e28596f6fcc99bd97e38c9b324163e0da90ed27562
Status: Downloaded newer image for centos:latest
63f4b8fce1bd44253bb420436da3ad5b8f532b253fc9e74ff52ad1b2f9844251
root@jim-Ubuntu1504:/home/jim/web# docker exec -i -t my_centos bash
Error response from daemon: Container 63f4b8fce1bd44253bb420436da3ad5b8f532b253fc9e74ff52ad1b2f9844251 is not running

No idea why it is exiting

root@jim-Ubuntu1504:/home/jim/web# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
63f4b8fce1bd        centos              "/bin/bash"              18 minutes ago      Exited (0) 18 minutes ago                       my_centos
f0ca8b9f4fa5        nginx               "nginx -g 'daemon off"   23 minutes ago      Up 23 minutes               80/tcp, 443/tcp     my_nginxtemp
bb9ab4958c33        nginx               "nginx -g 'daemon off"   About an hour ago   Up About an hour            80/tcp, 443/tcp     boring_aryabhata
886d174f641d        nginx               "nginx -g 'daemon off"   2 hours ago         Up 2 hours                  80/tcp, 443/tcp     mad_fermat
root@jim-Ubuntu1504:/home/jim/web# 

Tried to start but it exits , no idea why?

root@jim-Ubuntu1504:/home/jim/web# docker start 63f4b8fce1bd
63f4b8fce1bd
root@jim-Ubuntu1504:/home/jim/web# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES
63f4b8fce1bd        centos              "/bin/bash"              26 minutes ago      Exited (0) 2 seconds ago                       my_centos
f0ca8b9f4fa5        nginx               "nginx -g 'daemon off"   30 minutes ago      Up 30 minutes              80/tcp, 443/tcp     my_nginxtemp
bb9ab4958c33        nginx               "nginx -g 'daemon off"   About an hour ago   Up About an hour           80/tcp, 443/tcp     boring_aryabhata
886d174f641d        nginx               "nginx -g 'daemon off"   2 hours ago         Up 2 hours                 80/tcp, 443/tcp     mad_fermat
root@jim-Ubuntu1504:/home/jim/web# docker exec -i -t my_centos bash
Error response from daemon: Container 63f4b8fce1bd44253bb420436da3ad5b8f532b253fc9e74ff52ad1b2f9844251 is not running
root@jim-Ubuntu1504:/home/jim/web# 

Any help would be greatly appreciated.


(David Maze) #2

[quote=“bluemind2005, post:1, topic:14913, full:true”]
root@jim-Ubuntu1504:/home/jim/web# docker run -d --name=my_centos centos

root@jim-Ubuntu1504:/home/jim/web# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
63f4b8fce1bd        centos              "/bin/bash"              18 minutes ago      Exited (0) 18 minutes ago                       [/quote]

So here’s what’s going on:

  1. You say docker run -d centos. It fills in the default command (/bin/bash), starts the container, and returns.
  2. The container starts GNU bash.
  3. bash finds it doesn’t have a controlling terminal and standard input is closed, so it exits.

You need to tell the container to do something if you want to docker exec into it. sleep 9999999 could be an answer.

(Setting up a container to do nothing, but be able to docker exec into it, is a little unusual. If what you’re trying to set up to do is to hand-run a bunch of commands and then docker commit the result into an image, a much better path is to learn about Dockerfiles and the docker build command to be able to reproducibly build the same image.)


(Bluemind2005) #3

I now understand but I find it useless to have a container but do nothing.I am still not able to understand the use of docker. How to have CentOS as base images and open a shell.

What I really want is to have the ability to have basic CentOS image and then install websphere or weblogic application server, deploy app in that and run that docker app. Is that possible to do? How should I approach it?


(Lebnik) #4

docker run --rm -i -t centos:7.2.1511 bash


(Yatin03) #5

As we try to start container, it execute bash, and bash is not able to find controlling terminal due to which docker container for centos immediately stopped as it forms. To provide it terminal as well as run it in detach mode you can use:

docker container run -it --name centos7 -d centos:latest

This will run docker container in detach mode and also assign controlling terminal to bash due to which container will not stop.
Later to enter into container you can use:
docker container exec -it <container-id> bash