I’m fairly new to docker/containers. I have the below Dockerfile . Ultimately, I’m trying to run a specific version of Apache Httpd (contained within a zip file). The image builds without any issue. However, I can’t get the container to continuously run. To run, I using the following:
docker run -it <port-mappings> <my-image-name>
The container literally starts for a split second and exits.
Thanks for your help!!
# update OS
RUN yum -y update && \
yum -y install sudo unzip elinks krb5-workstation mailcap && \
yum clean all
RUN groupadd -g 48 -r apache
RUN /usr/sbin/useradd -c "Apache" -u 48 -g apache -s /sbin/nologin -r apache
RUN mkdir -p /opt/httpd
ADD jbcs-httpd24-httpd-2.4.51-RHEL7-x86_64.zip /opt/httpd
RUN unzip jbcs-httpd24-httpd-2.4.51-RHEL7-x86_64.zip
RUN cd jbcs-httpd24-2.4/httpd/
RUN chown -R apache:apache *
EXPOSE 80 443 6666
CMD ["/opt/httpd/jbcs-httpd24-2.4/httpd/sbin/apachectl", "-D", "FOREGROUND"]
Interesting. RUN pwd just shows the current working directory when docker build runs. It doesn’t effect how the container runs. At least it shouldn’t. Are you sure this was the solution and you didn’t change anything else to make it work?
By the way, do you know that this line does nothing, because each RUN instruction starts a new container to create a new filesystem layer?