美文网首页
Docker Alpine镜像 安装php7

Docker Alpine镜像 安装php7

作者: Lucus的随笔 | 来源:发表于2018-12-08 17:45 被阅读0次

    Alpine镜像安装php7后大小只有13M!!非常精简了!果断用上~
    运行拉取alpine 镜像

    docker run -dit --name php7.2-alpine -v D:\wwwroot:/var/www -p 8088:80 alpine:latest
    

    进入容器

    docker exec -it php7.2-min sh
    

    安装nginx和php7服务

    apk add nginx
    apk add php7 php7-fpm php7-opcache php7-curl php7-gd php7-mbstring php7-mysqli php7-json
    

    安装 rc-service

    apk add openrc --no-cache
    

    启动nginx

    service nginx start
    #或者rc-service nginx start
    

    遇到以下错误问题
    /lib/rc/sh/openrc-run.sh: line 273: can't create /sys/fs/cgroup/〜
    ...
    awk: /etc/network/interfaces: No such file or directory
    执行以下命令

    sed -i 's/#rc_sys=""/rc_sys="lxc"/g' /etc/rc.conf &&\
    echo 'rc_provide="loopback net"' >> /etc/rc.conf &&\
    sed -i 's/^#\(rc_logger="YES"\)$/\1/' /etc/rc.conf &&\
    sed -i '/tty/d' /etc/inittab &&\
    sed -i 's/hostname $opts/# hostname $opts/g' /etc/init.d/hostname &&\
    sed -i 's/mount -t tmpfs/# mount -t tmpfs/g' /lib/rc/sh/init.sh &&\
    sed -i 's/cgroup_add_service /# cgroup_add_service /g' /lib/rc/sh/openrc-run.s
    h &&\
    rm -rf /var/cache/apk/*
    

    又遇到问题
    WARNING: nginx is already starting
    运行

    /#  service nginx status
    * You are attempting to run an openrc service on a
     * system which openrc did not boot.
     * You may be inside a chroot or you may have used
     * another initialization system to boot this system.
     * In this situation, you will get unpredictable results!
     * If you really want to do this, issue the following command:
     * touch /run/openrc/softlevel
    /#  touch /run/openrc/softlevel
    touch: /run/openrc/softlevel: No such file or directory
    /#  mkdir -p /run/openrc
    /#  touch /run/openrc/softlevel
    /#  service nginx status
     * status: stopped
    /#  service nginx start
     * WARNING: nginx is already starting
    /#  /sbin/openrc
     * Caching service dependencies ...                                                 [ ok ]
    /#  rc-service nginx start
     * /run/nginx: creating directory
     * /run/nginx: correcting owner
     * Starting nginx ...                                                               [ ok ]
    

    启动php-fpm

    /#  service php-fpm7 start
     * Checking /etc/php7/php-fpm.conf ...
     * /run/php-fpm7: creating directory
     * Starting PHP FastCGI Process Manager ...                                        [ ok ]
    

    加入启动服务

    /#  rc-update add nginx default
    /#  rc-update add php-fpm7 start
    

    保存镜像

    /# commit php7.2-alpine liting68/php7.2-fpm-alpine
    

    拉取运行新镜像

    docker run -dit --name php7.2-alpine -v D:\wwwroot:/var/www -p 8088:80 liting68/php7.2-fpm-alpine /sbin/init
    

    完成

    相关文章

      网友评论

          本文标题:Docker Alpine镜像 安装php7

          本文链接:https://www.haomeiwen.com/subject/ahnqhqtx.html