Public Repository

Last pushed: 2 years ago
Short Description
Image for data containers proper to be mounted for symfony applications development.
Full Description

This image prepares a volume at /var/www/symfony and launchs an script to change www-data uid/gid to be aligned with that of the host user mounting its developing dir at the host to /var/www/symfony at the container.

Typical use case:

$:~/my-git-clone-dir>docker pull alianza/symfony-app
$:~/my-git-clone-dir>ls -ldn .
drwxrwxr-x 76 10001 0 4096 feb  4 14:06 .
$:~/my-git-clone-dir>docker run -d -v $(pwd):/var/www --name code-container \\
 -e USERID=10001 alianza/symfony-app

This runs a container with a /var/www/symfony dir with contents mounted from the working dir at the host. Owner and group for dir and files www-data at the container. If USERID is not specified the container will use 1000 as it is a reasonable debian default (first non root user created has 1000 as uid/gid).

Files for building this image:

Dockerfile:

FROM debian:wheezy

VOLUME /var/www/symfony

## www-data user config script
COPY www-data_conf.sh /usr/bin/www-data_conf.sh

CMD /usr/bin/www-data_conf.sh && tail -f /dev/null

www-data_conf.sh (755 permissions on the host):

#!/bin/bash
## Don't attempt to run if we are not root
if [ "$EUID" -ne 0 ]
    then echo "Please run as root"
    exit
fi

## Set defaults for environmental variables in case they are undefined
USERID=${USERID:=1000}

## (Docker cares only about uid, not username; diff users with same uid = confusion)
echo "Changing www-data uid&gid from 33 to $USERID"

groupmod -g $USERID www-data
usermod -u $USERID -g $USERID www-data
Docker Pull Command
Owner
alianza

Comments (0)