0
votes

I've started with IBM's image:

registry.ng.bluemix.net/ibmnode:latest

It's Ubuntu 14.04, I then add Apache2 on, do some file copies of my site, and then EXPOSE 443. Lastly, I invoke a bash script with the following:

#!/bin/bash
set -e
rm -f /usr/local/apache2/logs/httpd.pid
exec /usr/sbin/apache2ctl -DFOREGROUND

When I run the container locally, it works fine and serves up what I need. When BlueMix builds from the Dockerfile, that works without error. Then deploys to a container successfully. Immediately after deploy, the container registers as 'STOPPED'. Restarting brings it up and then back down within a few seconds. 'cf ic logs my-process-id' doesn't show any feedback.

Other things I've tried: ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"] Using service apache2 restart

Dockerfile:

FROM registry.ng.bluemix.net/ibmnode:latest

RUN apt-get install -y apache2
RUN apt-get install -y nano


# ADD SSL
RUN a2enmod ssl
RUN a2enmod proxy_http


WORKDIR /var/www/dist
RUN mv ./* /var/www/html

COPY docker/httpd-foreground.sh /usr/local/bin/
EXPOSE 443
CMD ["httpd-foreground.sh"]

httpd-foreground.hs:

#!/bin/bash
set -e
rm -f /usr/local/apache2/logs/httpd.pid
exec /usr/sbin/apache2ctl -DFOREGROUND
1
Any logs? Containers stop when the main application (PID 1) stops. - Webert Lima
None. And furthermore, I built the docker container locally, registered it with BlueMix registry, deployed it to a container and poof, it works fine. So the issue is limited to when the Dockerfile is processed and built within the BlueMix Build stage. - Brant
can you post the Dockerifle? Or at least show the ENTRYPOINT and CMD entries. - Webert Lima
Updated with script and with dockerfile above. - Brant
Weird. Can you try to debug and see if the exec part is returning immediately? Your bash script is PID 1 so the exec command should not return because it would close. Without any logs that's hard. You can also try to force wait the apacheprocess to finish removing the exec and -DFOREGROUND and putting & at the end, and then put waitpid $! in the next line. - Webert Lima

1 Answers

1
votes

What you are trying to do is getting node image, installing apache and overriding the command, and trying to run in the foreground. This is not really a good way to run a apache container on bluemix.

You should do something like this: 1. Follow information in here to pull the httpd image to your local, push the local image to your bluemix name space. - docker pull httpd:2.4 - docker tag httpd:2.4 registry.ng.bluemix.net//httpd - docker push registry.ng.bluemix.net//http 2. Once the image is pushed to your namespace, you can create custom image with your Dockerfile, note that I assume you have your website content in public-html folder

FROM registry.ng.bluemix.net//httpd:2.4 COPY ./public-html/ /usr/local/apache2/htdocs/ EXPOSE 80

  1. Build your image
cf ic build --tag myhttp .
  1. Run the container:
cf ic run --name myhttp -p 80 registry.ng.bluemix.net/<yourNameSpace>/myhttp
  1. Bind IP address, using
cf ic bind <IP> myhttp
  1. Access your container with the IP you bound