- Install Docker 1.9+ or askubuntu
- Pull the latest version of the image.
docker pull partychen/docker-nginx-phpfpm
Alternately you can build the image yourself.
git clone https://github.com/partychen/docker-nginx-phpfpm.git
cd docker-nginx-phpfpm
docker build -t="$USER/docker-nginx-phpfpm" .
Run the application container:
docker run --name app -d -p 8080:80 partychen/docker-nginx-phpfpm
The simplest way to login to the app container is to use the docker exec
command to attach a new process to the running container.
docker exec -it app bash
For development a volume should be mounted at /var/www/app/
.
The updated run command looks like this.
docker run --name app -d -p 8080:80 \
-v /host/to/path/app:/var/www/app/ \
partychen/docker-nginx-phpfpm
All the logs are forwarded to stdout and sterr. You have use the command docker logs
.
docker logs app
You can then simply split the stdout & stderr of the container by piping the separate streams and send them to files:
docker logs app > stdout.log 2>stderr.log
cat stdout.log
cat stderr.log
or split stdout and error to host stdout:
docker logs app > -
docker logs app 2> -
Create the file /etc/logrotate.d/docker-containers
with the following text inside:
/var/lib/docker/containers/*/*.log {
rotate 31
daily
nocompress
missingok
notifempty
copytruncate
}
Optionally, you can replace
nocompress
tocompress
and change the number of days.