我在https://github.com/Paritosh-Anand/Docker-Httpd-Tomcat
中的Docker(Docker for windows)中为ubuntu尝试了ApacheDockerfile是
FROM ubuntu:latest
MAINTAINER <user>@<domain>.com
RUN apt-get update && apt-get install -y --no-install-recommends apache2 libapache2-mod-jk
ADD apache2.conf /etc/apache2/apache2.conf
ADD 000-default.conf /etc/apache2/sites-enabled/000-default.conf
ADD worker.properties /etc/libapache2-mod-jk/workers.properties
ADD jk.conf /etc/apache2/mods-available/jk.conf
VOLUME ["/var/log/apache2"]
EXPOSE 80 443
CMD ["apachectl", "-k", "start", "-DFOREGROUND"]
但是,我需要在CentOs 7中运行Apache,而不是在ubuntu中运行。所以我将Dockerfile改为
FROM centos:7
MAINTAINER <user>@<domain>.com
RUN yum -y --setopt=tsflags=nodocs update
RUN yum -y --setopt=tsflags=nodocs install httpd
RUN yum -y --setopt=tsflags=nodocs install mod-jk
RUN yum clean all
ADD apache2.conf /etc/apache2/apache2.conf
ADD 000-default.conf /etc/apache2/sites-enabled/000-default.conf
ADD worker.properties /etc/libapache2-mod-jk/workers.properties
ADD jk.conf /etc/apache2/mods-available/jk.conf
VOLUME ["/var/log/apache2"]
EXPOSE 80 443
CMD ["apachectl", "-k", "start", "-DFOREGROUND"]
在跑步时,我收到错误
Step 5/13 : RUN yum -y --setopt=tsflags=nodocs install mod-jk
---> Running in a98487a9509c
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.nhanhoa.com
* extras: mirrors.nhanhoa.com
* updates: mirror.ehost.vn
No package mod-jk available.
Error: Nothing to do
ERROR: Service 'httpd' failed to build: The command '/bin/sh -c yum -y --setopt=tsflags=nodocs install mod-jk' returned a non-zero code: 1
这是镜子的问题吗?如何在操作系统为CentOs 7的docker中安装mod_jk? 我的主机操作系统是Windows 10
答案 0 :(得分:0)
对于centos 7,您需要从源代码编译模块。以下面的Dockerfile为例
FROM centos:7
RUN yum -y update && yum clean all
RUN yum -y install httpd httpd-devel gcc* make && yum clean all
# Install mod_jk
RUN curl -SL http://mirror.sdunix.com/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.40-src.tar.gz -o tomcat-connectors-1.2.40-src.tar.gz \
&& mkdir -p src/tomcat-connectors \
&& tar xzf tomcat-connectors-1.2.40-src.tar.gz -C src/tomcat-connectors --strip-components=1 \
&& cd src/tomcat-connectors/native/ \
&& ./configure --with-apxs=/usr/bin/apxs \
&& make \
&& cp apache-2.0/mod_jk.so /usr/lib64/httpd/modules/ \
&& ./libtool --finish /usr/lib64/httpd/modules/ \
&& cd / \
&& rm -rf src/ \
&& rm -f tomcat-connectors-1.2.40-src.tar.gz
# mod_jk conf files
ADD mod_jk.conf /etc/httpd/conf.d/
ADD workers.properties /etc/httpd/conf.d/
EXPOSE 80
# Simple startup script to avoid some issues observed with container restart
ADD run-httpd.sh /run-httpd.sh
RUN chmod -v +x /run-httpd.sh
CMD ["/run-httpd.sh"]
取自https://github.com/maeharin/apache-tomcat-docker-sample/blob/master/docker/httpd/Dockerfile