Public Repository

Last pushed: a year ago
Short Description
Php 5.6 (include redis extension) under alpine
Full Description

#!/bin/bash

NAME="local-php"
RUNUID=33
RUNUSER=docker-runner
VOLUMES="-v /data:/var/www"
LOGPATH="/data/log/fpm"

docker_run()
{
NEW_PID=docker run \ -dit \ --restart=always \ --name $NAME \ -v $LOGPATH:/var/log/php-fpm \ $VOLUMES \ andrewlees/alpine-php5.6

ORIGIN_USERNAME=`docker exec $NAME getent passwd "$RUNUID" | cut -d: -f1`
if [[ "$ORIGIN_USERNAME" == "" ]]; then
    docker exec $NAME adduser -D -H -u $RUNUID $RUNUSER
else
    RUNUSER=$ORIGIN_USERNAME
fi

FPMCONF=/etc/php5/php-fpm.conf
docker exec $NAME cp $FPMCONF $FPMCONF.default
docker exec $NAME php -r "file_put_contents('$FPMCONF', str_replace(array(';listen.owner = web', ';listen.group = web', ';listen.mode = 0660', 'user = web', 'group = web'), array('listen.owner = $RUNUSER', 'listen.group = $RUNUSER', 'listen.mode = 0755', 'user = $RUNUSER', 'group = $RUNUSER'), file_get_contents('$FPMCONF')));"

./nginx-start.sh -f

echo $NEW_PID

}

PS=docker ps -a | grep $NAME

if [[ "$PS" != "" ]]; then
if [[ "$1" == "-f" ]]; then
docker stop $NAME > /dev/null
docker rm $NAME > /dev/null
PID=docker_run
else
if [[ $PS != " Up " ]]; then
docker start $NAME > /dev/null
fi
PID=echo $PS | awk '{print $1 ""}'
fi
else
PID=docker_run
fi

docker exec -d $PID php-fpm

exit 0

Docker Pull Command
Owner
andrewlees