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
Written by Gabriel Santerre
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Docker
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#