centos7 container is restarting again & again itself

+1 vote

I have been trying to run centos7 container by using following Docker compose file and Dockerfile-

version: "2"    data:
    build:
      context: ./docker-build
      dockerfile: Dockerfile.data
    restart: always
    ports:
      - "8082:8082"
    command: bash
Dockerfile:
FROM centos:7
RUN yum -y update
CMD /bin/sh

That centos7 container is restarting continuously and I am unable to figure out the reason for it and need help to resolve it?

Apr 3, 2018 in DevOps & Agile by Atul
• 10,240 points
33 views

1 answer to this question.

0 votes

Usually Containers stop once their main process exits but in your case, the main process is a shell (/bin/sh or bash). A shell without a TTY attached exits immediately.

If you want to keep your container running, add a TTY to the container;

When using docker run;

Run a container interactively;

docker run -it centos:7 bash

Run the container in the background ("detached", -d);

docker run -dit centos:7 bash

When using a 

docker-compose.yml:

version: "2"
services:
  data:
    build:
      context: ./docker-build
      dockerfile:
Dockerfile.data
    restart: always
    ports:
      - "8082:8082"
    command: bash
    tty: true
answered Apr 3, 2018 by shubham
• 6,870 points

Related Questions In DevOps & Agile

0 votes
1 answer

Is it possible to preserve local ivy repository in Bluemix BUILD & DEPLOY?

You're right--the pipeline spins up a new ...READ MORE

answered Jul 19, 2018 in DevOps & Agile by Atul
• 10,240 points
21 views
0 votes
1 answer

Error: Windows container is unavailable via localhost

This is because, containers and their ports are ...READ MORE

answered Sep 3, 2018 in DevOps & Agile by Sophie may
• 9,430 points
17 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,160 points
101 views
+2 votes
1 answer

What is the difference between a container and an image in Docker?

 Below is reference which you can follow to know ...READ MORE

answered Sep 20, 2018 in DevOps & Agile by shubham
• 6,870 points
40 views
+1 vote
2 answers

is it possible to assign a Feature/User Story/Task to a team [Group] in VSTS

In most cases, we would break Work ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,100 points
548 views