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
1,156 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
• 7,340 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
555 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
• 10,620 points
780 views
+2 votes
1 answer
+2 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
• 58,020 points
2,714 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
• 7,340 points
1,202 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,220 points
5,432 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP