简体   繁体   English

从自定义dockerfile到kubernetes,使用Apache启动部署

[英]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. 我有一个泊坞窗文件,其中使用一些自定义配置等构建了一个Apache Web服务器。

Executing the Dockerfile I create an image that could be used in a deployment yaml file using Kubernetes. 执行Dockerfile,我创建了一个映像,该映像可使用Kubernetes在部署yaml文件中使用。 Everything is working properly but after deployment, my apache service is down in every container of every pod. 一切工作正常,但是部署后,我的apache服务在每个pod的每个容器中都关闭了。

Obviously I can access in every container to execute an /etc/init.d/apache2 start but this solution is not very smart.. 显然,我可以在每个容器中访问以执行/etc/init.d/apache2 start,但是此解决方案不是很聪明。

So my question is: how can I set my custom apache to be running during the execution of the deploy yaml file? 所以我的问题是:如何在部署yaml文件执行期间将自定义apache设置为正在运行?

PS: I tried this solution: with the dockerfile I created a docker container then I accessed on it and I started apache. PS:我尝试过这种解决方案:使用dockerfile创建了一个docker容器,然后对其进行访问并开始使用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 然后我从该容器创建了一个新映像(dockerfile commit + gcloud image push),但是当我部署应用程序时,我总是发现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. 首先,首先-我非常建议您仅使用官方的apache2映像 ,然后从那里进行自定义配置。 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. 要自定义httpd服务器的配置,只需以/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. 您会注意到,在正式映像的Dockerfile内部,它们正在BASH脚本中复制,然后将其设置为CMD选项。 This works because when running a Docker container you should be running a single process ; 之所以有效,是因为在运行Docker容器时您应该运行一个进程 ; 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. 您可以在这里找到他们正在运行的脚本,它只有7行,非常短-因此,您不必费劲就能确定从此处开始的位置。

Best of luck! 祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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