Skip to content

Instantly share code, notes, and snippets.

@thomasleveil
Last active August 29, 2015 14:07
Show Gist options
  • Save thomasleveil/c48e100d819d408f1e58 to your computer and use it in GitHub Desktop.
Save thomasleveil/c48e100d819d408f1e58 to your computer and use it in GitHub Desktop.

See stackoverflow question 26087484

Instructions

Build the image with

make build

Run the container with

make run

Hit Ctrl+c to stop and delete the container

<VirtualHost *:80>
ServerAdmin me@mydomain.com
DocumentRoot /var/www/site
<Directory /var/www/site/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
FROM debian:squeeze
MAINTAINER Name < email : >
# Update the repository sources list
RUN apt-get update
# Install apache, PHP, and supplimentary programs. curl and lynx-cur are for debugging the container.
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 build-essential php5 mysql-server openssh-server libapache2-mod-php5 php5-mysql php5-gd php-pear php-apc php5-curl curl lynx-cur
# Enable apache mods.
RUN a2enmod php5
RUN a2enmod rewrite
# Manually set up the apache environment variables
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
EXPOSE 80
# Copy site into place.
ADD www /var/www/site
# Update the default apache site with the config we created.
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
# Start mysql and apache
CMD bash -c '(mysqld &); /usr/sbin/apache2ctl -D FOREGROUND'
EXPOSE 3306
// save this file in a 'www' directory
<?php
$connect=mysql_connect("localhost:3306","root","") or die("Unable to Connect");
echo "connected to mysql";
?>
DOCKER_IMAGE = so-26087484
DOCKER_CONTAINER = so-26087484
PORTS = -p 8000:80
DOCKER_OPTS = -c=1 -m="512m"
build:
docker build --force-rm -t $(DOCKER_IMAGE) .
run:
docker run --rm -it $(PORTS) $(DOCKER_OPTS) --name $(DOCKER_CONTAINER) $(DOCKER_IMAGE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment