Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CentOS image is not running?

Tags:

docker

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# 

Started the container but no idea why it is exiting

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# 

PS: Can someone disable the restriction to post once every 90 mins ??? Learning has to be spontaneous and interactive.

like image 353
learner Avatar asked Jun 08 '16 08:06

learner


People also ask

How do I run a docker image?

To run an image inside of a container, we use the docker run command. The docker run command requires one parameter and that is the image name. Let's start our image and make sure it is running correctly. Execute the following command in your terminal.

Does docker work on CentOS?

To install Docker Engine, you need a maintained version of CentOS 7, CentOS 8 (stream), or CentOS 9 (stream). Archived versions aren't supported or tested.


3 Answers

You are looking for running centos container in detached mode. Try the following...

sudo docker run -d -it centos

like image 66
Ahab Avatar answered Sep 20 '22 14:09

Ahab


if you look at the Dockerfile of the latest image of CentOS, you will notice the last line, from here:

CMD ["/bin/bash"]

So you launch a container that has a shell, it exists and that is all.

Try:

docker run -it --name=my_centos centos sleep infinity

or any variant.

By the way, when you do

root@jim-Ubuntu1504:/home/jim/web# docker exec -i -t my_centos bash

you suppose that your container is running, which here, is not.

Check with:

docker ps -a --filter="name=my_centos"

that your container is up.

like image 21
user2915097 Avatar answered Sep 18 '22 14:09

user2915097


You have to run the image in interactive mode to be able to connect to it.

docker run -it centos

The -it instructs Docker to allocate a pseudo-TTY connected to the container’s stdin; creating an interactive bash shell in the container.

You can expect this after running that command.

docker@default:~$ docker run -it centos [root@0c3c7d59b91c /]#

like image 33
ssasi Avatar answered Sep 22 '22 14:09

ssasi