Building a NGINX PHP7 PHP-FPM with docker and docker-compose

Setting up Nginx

We’ll start by getting a web server and based on our requirements this will be a container running the official Nginx image. Since we’ll be using Docker Compose, we will create the following docker-compose.yml file, which will run the latest Nginx image and will expose its port 80 to port 8080:

image: nginx:latest
– « 8080:80 »
Now we can run

docker-compose up
This should give you the default Nginx screen on port 8080 for localhost or the IP of your docker machine.

Now that we have a server let’s add some code. First we have to update the docker-compose.yml to mount a local directory. I will use a folder called code, which is in the same directory as my docker-compose.yml file, and it will be mounted as root folder code in the container.

image: nginx:latest
– « 8080:80 »
– ./code:/code
The next step is to let Nginx know that this folder exists.
Let’s create the following site.conf on the same level as the docker-compose.yml file:

server {
index index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;
If you don’t have a lot of experience with Nginx, this is what we define here – index.html will be our default index, the server name is php-docker.local

To activate this setup we need to apply yet another modification to our docker-compose.yml file:

image: nginx:latest
– « 8080:80 »
– ./code:/code
– ./site.conf:/etc/nginx/conf.d/site.conf
This will add site.conf to the directory where Nginx is looking for configuration files to include. You can now place an index.html file in the code folder with contents that is to your heart’s delight. And if we run

docker-compose up
again, the index.html file should be available on php-docker.local:8080.

Adding PHP-FPM

Now that we have Nginx up and running let’s add the PHP in the game. The first thing we’ll do is pull the official PHP7-FPM repo and link it to our Nginx container. Our docker-compose.yml will look like this now:

image: nginx:latest
– « 8080:80 »
– ./code:/code
– ./site.conf:/etc/nginx/conf.d/site.conf
– php
image: php:7-fpm
The next thing to do is configure Nginx to use the PHP-FPM container for interpreting PHP files. Your updated site.conf should look like this:

server {
index index.php index.html;
server_name php-docker.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /code;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
In order to test this let’s rename the index.html file to index.php and replace its content with the standard:

mobydock father

More Posts - Website

Follow Me:


tis is IT , Next week !!!!

Wednesday, Jun 29, 2016 – Friday, Jul 1, 2016

The Program
30 June – Thursday
08:00-09:00 Registration, Breakfast, and Sponsor Booths Open
09:00-09:15 Opening Welcome
09:15-09:55 Erica Baker (Slack)
Opening Keynote
09:55-10:00 Sponsors
10:00-10:40 Adam Jacob (Chef)
The Evolution of Automation
10:40-10:45 Break
10:45-11:15 Daniël van Gils (Cloud66)
How the hell do I run my microservices in production, and will it scale?
11:15-11:30 Sponsors
11:30-12:00 Warner Moore (CoverMyMeds)
DevOps has Always Been About Security
12:00-13:00 Lunch (catered)
13:00-13:30 Avishai Ish-Shalom (Fewbytes)
The Mathematics of Reliability
13:30-13:45 Sponsors
13:45-14:15 Ignites
Jody Wolfborn (Chef) – You Don’t Belong Here: Dealing with Imposter Syndrome
Pavel Chunyayev (Levi9) – The importance of ‘why’ for software operations.
Takahiko Ito – Document Writing in CI Environment
Jason Yee (Datadog) – Breaking Brooks’ Law with DevOps.
14:15-15:00 Open Space
Open Space Opening Workshopping Bias:
Designing Solutions to
Improve Decision Making
and Unleash Your Team’s Potential
15:00-15:15 Break
15:15-15:45 Attendee Driven
Open Space #1
breakout discussions
15:45-16:00 Break
16:00-16:30 Attendee Driven
Open Space #2
breakout discussions
16:30-17:00 Closing
17:00-18:00 Sponsor happy hour (Sponsored by Red Hat)
18:00-20:00 BBQ (Sponsored by Chef) & Band
1 July – Friday
08:30-09:20 Registration, Breakfast, and Sponsor Booths Open
09:20-09:30 Opening Welcome
09:30-10:00 Ken Mugrage (Thoughtworks)
What we’re learning about burnout and how a DevOps culture can help
10:00-10:10 Sponsors
10:10-10:40 Victoria Jeffrey (Chef)
Preparing for the Day After Tomorrow – Test-Driven Infrastructure
10:40-10:50 Break
10:50-11:20 Desmond Delissen
Continuous testing in the world of APIs
11:20-11:30 Sponsors
11:30-12:00 Harm Weites (Wehkamp)
One engineer, four environments, no termination protection.
12:00-13:00 Lunch (catered)
13:00-13:45 Ignites
Will Button (Trax) – An ElasticSearch Cluster Named George Armstrong Custer
Bernd Erk – Working in and with Open Source Communities
Hannah Foxwell (Pendrica) – Systems are Simple. Humans are Complex.
Gopal Ramachandran (TMNS) – Test driven Dockerized infrastructure
Marco Ceppi – Open Source Operations – punching up
13:45-14:30 Open Space
Open Space Opening
14:30-15:00 Attendee Driven
Open Space #1
breakout discussions
Security Talk Track:
Melanie Rieback (Radically Open Security)
Pentesting ChatOps
15:00-15:15 Break
15:15-15:45 Attendee Driven
Open Space #2
breakout discussions
Security Talk Track:
Guy Podjarny (Snyk)
Writing Secure Node Code
15:45-16:15 Attendee Driven
Open Space #3
breakout discussions
16:15-16:45 Closing

mobydock father

More Posts - Website

Follow Me:

Splunk – universal forwarder on Raspberry Pi 3 and Splunk enterprise on Labtop

A little post to explain how i succeed to deploy a splunk forwarder on a raspberry pi 3

First install the client splunk enterprise on your labptop
Then configure it to accept receiving data on port 9997
In the upper right, click the dropdown for “Settings”. Under Data, click Forwarding and receiving, and you will be taken to the configuration page where you can set Splunk to listen for data from your Pi.

Click “configure receiving”, and you will be taken to the receive data configuration page. Assuming this is a brand new installation of Splunk, you will have no configurations. Click “New” and you will be taken to the new configuration wizard. For now, we will just add a new listener at port 9997, and click Save.

Then install the universal forwarder on your RPI :

Download the Universal Forwarder from to your Pi

You’ll find some help on

but it ‘s not necessary

just download the .tar file and use : tar -xvf …. to unzip it

One important thing to know when installing the Universal Forwarder on *nix, is that the default install does NOT autorun on boot.
You can set it to autostart running the following as root:
$SPLUNK_HOME/bin/Splunk enable boot-start

To start Splunk on your forwarder, navigate to $SPLUNK_HOME /bin/ and run ./splunk start. You’ll see the standard output for startup.
At the next prompt, run ./splunk version, and you should see the version output for ARM Linux.

Congratulations, the Splunk Universal Forwarder is running on your Raspberry Pi!

Now, create a script which will be played by splunk to extract data :

edit file : $SPLUNK_HOME/bin/scripts

#! /bin/sh
for c in $(seq 1 60)
TIME=$(date +"%D %T.%3N %Z")
TEMP=$(vcgencmd measure_temp)
VOLTS=$(vcgencmd measure_volts)
CPU_TEMP=`echo $TEMP | cut -d \' -f 1`
VOLTS=`echo $VOLTS | cut -d V -f 1`
echo "time=$TIME|$VOLTS|$CPU_TEMP"
sleep 1

Then edit :

host = raspberrypi
index = main
interval = 60
source = cpu_details
sourcetype = pi_system_scripts

Then edit :

# Version 6.0

Where XX… is the IP of your labtop

BE CAREFUL to accept on your labtop firewall (Windows) the port 9997
if you don’t you will have in the log file on the rpi in $SPLUNK_HOME/var/log/splunk/splund.log
the error :

connection to ip=ip.address:9997 timed out

When it done just start splunk on the RPI :
$SPLUNK_HOME/bin/splunk start

and you ll receive data on the search screen of the plunk enterprise client installed on your labtop :

CONGRATULATION !! and have fun

mobydock father

More Posts - Website

Follow Me:

Raspberry PI ZERO

The raspberry PI ZERO : the 5$ computer


A Broadcom BCM2835 application processor
1GHz ARM11 core (40% faster than Raspberry Pi 1)
A micro-SD card slot
A mini-HDMI socket for 1080p60 video output
Micro-USB sockets for data and power
An unpopulated 40-pin GPIO header
Identical pinout to Model A+/B+/2B
An unpopulated composite video header
Our smallest ever form factor, at 65mm x 30mm x 5mm

I bought it yesterday and wait for te delivery

Will keep you in touch when tested

mobydock father

More Posts - Website

Follow Me:

HowTo build an Docker infrastructure

What :

An infrastructure based on Varnish + Nginx + PHP-FPM + MariaDB

On Docker Containers

Why :

For a personnal blog or website


How : Build,Ship, Run

(Because the what is famous , we won’t do it from Dockerfiles . We will use Dockerhub images)

Step 1:

mkdir p $HOME/data/webstack/conf $HOME/data/webstack/www


Step 2: install NGinx

docker pull nginx

Controle your image with docker images

Launch your container

docker run name webstack_nginx_1 v $HOME/data/webstack/www:/usr/share/nginx/html:ro p 8080:80 d nginx
You can control by open your navigator and try
Our container name is  webstack_nginx_1, the port TCP/8080 of our host will be tranfer to the port TCP/80 of the container (default port for NGinx) and it assigne in readonly the directory volume : /usr/share/nginx/html to the host directory $HOME/data/www .
To test we create some static pages :
echo « My first page » > $HOME/data/webstack/www/index.html
echo « <?php phpinfo(); ?>«  > $HOME/data/webstack/www/phpinfo.php
You can also confirm tha everythnig work fine by using :
curl http://localhost:8080
it will say : « My first page »
Step 3 : PHP-FPM

docker pull jprjr/phpfpm

Let run the container :

docker run name webstack_php_01 p 9000:9000 d jprjr/phpfpm


Step 4 : Make them talk together

Docker option : –link

We will copy the nginx configfile to the host

docker cp webstack_nginx_1:/etc/nginx/nginx.conf $HOME/data/webstack/conf/nginx.conf



vi $HOME/data/webstack/conf/nginx.conf


Add the server part


daemon off;
user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/;
events {
    worker_connections  1024;
http {
    include       /etc/nginx/mime.types;
    default_type  application/octetstream;
    log_format  main  ‘$remote_addr – $remote_user [$time_local] « $request » ‘
                      ‘$status $body_bytes_sent « $http_referer » ‘
                      ‘ »$http_user_agent » « $http_x_forwarded_for »‘;
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   /usr/share/nginx/html;
        # Pass PHP scripts to PHP-FPM
        location ~* \.php$ {
            fastcgi_index   index.php;
            fastcgi_pass    webstack_php:9000;
            #fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            include         fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME    /srv/http$fastcgi_script_name;
            fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
        # deny access to .htaccess files, if Apache’s document root
        # concurs with nginx’s one
        location ~ /\.ht {
            deny  all;



In our usecase we need that the nginx container webstack_nginx_1 can communicate with the PHP container (webstack_php_01).

We delete the existing containers

docker stop webstack_php_01 && docker rm webstack_php_01

docker stop webstack_nginx_1 && docker rm webstack_nginx_1


And we recreate them by using a docker-compose command

Before create a docker-compose.yml file


image: jprjr/php-fpm
– « 9000:9000 »
– $HOME/data/webstack/www:/srv/http

image: nginx
– « 8080:80 »
– $HOME/data/webstack/www:/usr/share/nginx/html
– $HOME/data/webstack/conf/nginx.conf:/etc/nginx.conf
– php


Then run the command

docker-compose up


and try it :

curl http://localhost:8080






mobydock father

More Posts - Website

Follow Me: