ieisxg
Last Updated: April 13, 2016
·
348
· gabrielsanterre
4862c790a5484ff535c2ebee53189d72

Script to create a container with php and apache

Run

sudo sh ./docker-container-php.sh container-name 8080

Script

#!/bin/bash

CONTAINER_NAME=$1
HOST_PORT=$2
HOST_DIR=$(pwd)

echo '### Creating docker container: ' $CONTAINER_NAME
sudo docker run -d -p $HOST_PORT:80 --name $CONTAINER_NAME -v $HOST_DIR:/var/www/html php:7.0-apache

echo '### Activating mod-rewrite'
sudo docker exec $CONTAINER_NAME a2enmod rewrite

echo '### Restarting apache 2'
sudo docker exec $CONTAINER_NAME service apache2 restart

echo '\n### Restart container ' $CONTAINER_NAME
sudo docker restart $CONTAINER_NAME
Say Thanks
Respond
Filed Under