dockerfile自定义php-fpm镜像文件

半兽人 发表于: 2020-03-02   最后更新时间: 2020-03-02 21:04:18  
{{totalSubscript}} 订阅, 2,172 游览

yum安装方式

Dockerfile

FROM docker.io/openshift/base-centos7:latest
RUN yum makecache
RUN yum -y install php-fpm php php-gd php-mysql php-mbstring php-xml php-mcrypt  php-imap php-odbc php-pear php-xmlrpc  
RUN sed -i 's/listen = 127.0.0.1:9000/listen = 0.0.0.0:9000/' /etc/php-fpm.d/www.conf
RUN sed -i 's/listen.allowed_clients = 127.0.0.1/;listen.allowed_clients = 127.0.0.1/' /etc/php-fpm.d/www.conf

EXPOSE 9000
CMD ["/sbin/php-fpm"]

执行编译

docker build -t registry.my.cn/php:0.1 .
docker push registry.my.cn/php:0.1

jar包安装方式

Dockerfile

FROM hub.c.163.com/library/centos:latest

RUN echo "Asia/shanghai" > /etc/timezone;
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ENV LANG en_US.UTF-8

RUN mkdir /usr/local/software && cd /usr/local/software
RUN yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
RUN cd /usr/local/software && wget https://www.php.net/distributions/php-7.2.28.tar.gz && ls /usr/local/software && tar -xvf php-7.2.28.tar.gz && cd /usr/local/software/php-7.2.28 && ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --without-pear  --disable-phar --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl && make && make install
RUN mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
RUN mv /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
RUN echo "export PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH" >> /etc/profile && source /etc/profile

执行编译

docker build -t registry.my.cn/php-jar:0.1 .
docker push registry.my.cn/php-jar:0.1
更新于 2020-03-02
在线,3小时前登录

查看php-fpm更多相关的文章或提一个关于php-fpm的问题,也可以与我们一起分享文章