简体   繁体   中英

From custom dockerfile to kubernetes deploy with an apache started

I have a dockerfile where I build an apache web server with some custom configurations etc.

Executing the Dockerfile I create an image that could be used in a deployment yaml file using Kubernetes. Everything is working properly but after deployment, my apache service is down in every container of every pod.

Obviously I can access in every container to execute an /etc/init.d/apache2 start but this solution is not very smart..

So my question is: how can I set my custom apache to be running during the execution of the deploy yaml file?

PS: I tried this solution: with the dockerfile I created a docker container then I accessed on it and I started apache. Then I created a new image from this container (dockerfile commit + gcloud image push) but when I deploy the application I always find apache down

Well, first things first - I would very much recommend just using the official apache2 image and then making your custom configurations from there. They're documentation states this in the following paragraph:

Configuration

To customize the configuration of the httpd server, just COPY your custom configuration in as /usr/local/apache2/conf/httpd.conf.

FROM httpd:2.4
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf

However if you're dead-set on building everything yourself; you'll notice that inside of the Dockerfile for the official image they are copying in a BASH script and then setting this as the CMD option. This works because when running a Docker container you should be running a single process ; this is why, as you stated, running it from it's service is a bad idea.

You can find the script they're running here , it's very short at 7 lines - so you shouldn't have too much trouble figuring out where to go from here.

Best of luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM