Home:ALL Converter>Ubuntu Docker container immediately stops, issue with Dockerfile?

Ubuntu Docker container immediately stops, issue with Dockerfile?

Ask Time:2019-04-04T21:38:33         Author:sonashii

Json Formatter

I'm pretty new to Docker, and completely baffled as to why my container exits upon start.

I've built an Ubuntu image of which starts Apache and fail2ban upon boot. I'm unsure as to whether it's an issue with the Dockerfile, or the command I am running to start the container.

I've tried:

docker run -d -p 127.0.0.1:80:80 image
docker run -d -ti -p 127.0.0.1:80:80 image
docker run -d -ti -p 127.0.0.1:80:80 image /bin/bash

The Dockerfile is as follows:

FROM ubuntu:latest

RUN \
  apt-get update && \
  apt-get -y upgrade && \
  apt-get install -y build-essential && \
  apt-get install -y iptables && \
  apt-get install -y software-properties-common && \
  apt-get install -y apache2 fail2ban && \
  rm -rf /etc/fail2ban/jail.conf

ADD index.html /var/www/html/
ADD jail.conf /etc/fail2ban/

ENV  HOME /root
WORKDIR /root

EXPOSE 80 443

ENTRYPOINT service apache2 start && service fail2ban start
CMD ["bash"]

I can jump into the container itself with:

docker exec -it image /bin/bash

But the moment I try to run it whilst staying within the host, it fails. Help?

Author:sonashii,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55517408/ubuntu-docker-container-immediately-stops-issue-with-dockerfile
vladmihaisima :

Considering your question, where you mention \"upon boot\" I think it would be useful to read https://docs.docker.com/config/containers/multi-service_container/.\n\nIn a nutshell docker containers do not \"boot\" as a normal system, they start a process and execute it until it exits. \n\nSo, if you want to start two processes you can do a wrapper script as explained at the link above.",
2019-04-04T14:04:27
yy