1、首先来个官方centos7的dockerfile,可建立最基础的centos7镜像放到自己harbor上(73M)
FROM centos:7
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]
2、根据以上镜像建立其它环境 nginx(1.20.1)+php(7.4)? (515M)
FROM registry.yoyi.tv/yoyi/centos7:latest
ENV TZ=Asia/Shanghai
ENV LANG=en_US.UTF-8
COPY CentOS-Base.repo epel-7.repo yoyi.repo /etc/yum.repos.d/
RUN yum clean all && yum makecache && yum -y update && \
rpm -i https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm --nodeps &> /dev/null && \
yum install -y supervisor nginx &> /dev/null && \
yum install -y epel-release https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm &> /dev/null && \
yum -y install php php-bcmath php-Core php-ctype php-curl php-date php-dom php-fileinfo php-filter php-ftp php-gd php-gettext \
php-hash php-iconv php-intl php-json php-libxml php-mbstring php-mysqli php-mysqlnd php-openssl php-pcntl php-pcre php-PDO \
php-pdo_mysql php-pdo_sqlite php-Phar php-posix php-Reflection php-session php-shmop php-SimpleXML php-soap php-sockets php-SPL \
php-sqlite3 php-standard php-sysvsem php-tokenizer php-xml php-xmlreader php-xmlrpc php-xmlwriter php-xsl php-zip php-zlib \
php-fpm --enablerepo=remi-php74 &> /dev/null && \
groupadd www && useradd -g www -s /sbin/nologin www && \
mkdir -p /data/nginx/conf.d /data/nginx/log /data/php-fpm/logs /home/wwwroot /home/wwwlogs && \
sed -i 's/listen = 127.0.0.1:9000/listen = 9000/g' /etc/php-fpm.d/www.conf && sed -i 's/listen.allowed_clients = 127.0.0.1/;listen.allowed_clients = 0.0.0.0/g' /etc/php-fpm.d/www.conf && \
yum clean all && rm -rf /var/cache/yum/*
COPY supervisord.conf /etc/supervisor/supervisord.conf
COPY supervisord.conf /etc/supervisord.conf
COPY nginx.conf /etc/nginx/nginx.conf
COPY php-fpm.conf /etc/php-fpm.conf
COPY www.yoyi.com.cn.conf /etc/nginx/vhost/
VOLUME /home/
EXPOSE 80
ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]
|