Wednesday, May 25, 2022

[SOLVED] Docker container CentOs with Apache

Issue

I'm toying around with Docker. But i have an issue with Docker when trying to build a Centos and Apache Server in a container. I run Docker on my Windows 10 Machine. The CentOS + Apache container, is coupled with a Maria DB image.

When i do the docker-compose my Apache container starts and imediateliy shut down with exit code 0.

Here's my dockerfile :

FROM centos:centos7
LABEL Author = "Aurelien H."
LABEL Description = "DOCKERFILE : Allows the creation of a Container with a Centreon distribution installed via packages"

#Update and install requirements
RUN yum update -y
RUN yum install -y wget nano centos-release-scl httpd git

#Install Centreon repo
RUN cd /usr/local/src
RUN wget http://yum.centreon.com/standard/3.4/el7/stable/noarch/RPMS/centreon-release-3.4-4.el7.centos.noarch.rpm
RUN yum install -y --nogpgcheck centreon-release-3.4-4.el7.centos.noarch.rpm

#Install Centreon
RUN yum install -y centreon-base-config-centreon-engine centreon centreon-pp-manager
RUN yum clean all
#RUN systemctl enable httpd.service
#RUN systemctl start httpd.service
EXPOSE  80
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]

Here's my docker compose.

centreon:
  build: ./centreon
  ports:
    - "80:80"
#  volumes:
#    - "./data"
  links:
   - mariadb
mariadb:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: notR00tPassword

Solution

I needed to use the "docker-compose up --build" command. It rebuild the images before executing them. Problem solved.



Answered By - Aurelien
Answer Checked By - Robin (WPSolving Admin)