Docker Community Forums

Share and learn in the Docker community.

Httpd service not starting in Alpine container

Hello,

Trying to run both java and http service in a single Alpine image, somehow httpd service not starting

below is the dockerfile used

FROM java:8-jdk-alpine
RUN apk add --no-cache apache2-proxy apache2-ssl apache2-utils

WORKDIR /var/www/
COPY html/ .

WORKDIR /var/backed
COPY backed-0.0.1-SNAPSHOT.jar .

EXPOSE 80/tcp
EXPOSE 8085/tcp

CMD [β€œsh”,"-c","/usr/sbin/httpd -D FOREGROUND && java -jar /var/backed/backed-0.0.1-SNAPSHOT.jar"]

Docker run command:
sudo docker run -p 8080:80 -p 8085:8085 server:1.0

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.2. Set the β€˜ServerName’ directive globally to suppress this message

    β–ˆβ–ˆβ•— β–ˆβ–ˆβ•—   β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
    β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β•šβ•β•β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•”β•β•β•β•β• β•šβ•β•β–ˆβ–ˆβ•”β•β•β• β–ˆβ–ˆβ•”β•β•β•β•β•β• β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—
    β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—     β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•

β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β•β• β•šβ•β•β•β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘
β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β• β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ•—
β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β• β•šβ•β•β•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•β•β•β•β•β•β• β•šβ•β• β•šβ•β•

:: JHipster :nerd_face: :: Running Spring Boot 2.1.8.RELEASE ::
:: https://www.jhipster.tech ::

Posted snipped of the container run above, I think the httpd service quits immediately.

I could able to view jhipster home page on 172.17.0.2:8085, but frontend 172.17.0.2:8080 or 172.17.0.2 is connection timed out.

How can make the front end work?

Thanks,
Mohan

With the syntax command1 && command2, command2 is run only when command1 is done and successfully. That’s probably not what you meant with that CMD line in your Dockerfile.
You’ll need to write a script for that.

What happen is : apache fail, then your java app is started. Here is the only message apache says :

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 172.17.0.2. Set the β€˜ServerName’ directive globally to suppress this message

You might want to fix it’s configuration.

But IMHO, you should use distinct containers for each services, which mean 1 container for your java app and one for apache (then you could even just use the httpd:alpine and overwrite it’s configuration file with a docker config create .... config.). All you have to do is to write a simple docker-compose.yaml file :wink:

1 Like

Thanks sebt3 for the response