docker - 在 docker for windows 上的 centos 7 中安装 mod_jk

标签 docker centos docker-compose centos7

我在 https://github.com/Paritosh-Anand/Docker-Httpd-Tomcat 中尝试了 Apache for ubuntu in Docker (Docker for windows)

Dockerfile 是

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

最佳答案

对于 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

关于docker - 在 docker for windows 上的 centos 7 中安装 mod_jk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46168128/

相关文章:

postgresql - 如何使用卷将数据保存在 dockerized postgres 数据库中

postgresql - 如何将Docker容器连接到远程Postgresql

python - pip3 install isal 在 Ubuntu 18 中失败,但在 Ubuntu 20 中运行良好(dockerized 场景)

docker - Docker多个IP地址

linux - 如何更改docker服务的用户?

python - Certbot 无法在 CentOS 6 服务器上运行

java - 在 Centos 上安装 Java

docker - 如何在Kubernetes下使用Fail2ban?

centos - Chef 节点未向服务器注册

docker - docker-compose.yml 端口上的引用有什么不同吗?