Docker + nginx + Php-FPM 502 Bad Gateway
Solution 1:
Ok, I solved my problem, that's how I did it:
docker run -i -t ubuntu /bin/bash
Then I looked at the nginx logs that indicated a problem with the upstream php fpm server as shown above
tail -f /var/log/nginx/*
Finally I restart the php5-fpm service
service php5-fpm restart
So finally my problem is that during the installation of container service was launched but with php misconfiguration and thus restarting the service has reloaded the php5-fpm configuration
Solution 2:
You are making the faulty assumption that a docker container is just another machine or vm. With Docker should always try to run one thing only per container. You are then supposed to use links and volumes to make them talk together.
CMD should start the program directly and the daemon should instead be configured to run in the foreground, thus not as a service. Logs should preferably also be forwarded to docker but that is a bit beyond me (see the official app builds on github).
Also make sure that certain things are not run as root, because Docker does not offer proper security isolation features at this time.
In the end your issue is resolved by taking a look at their newly improved documentation and learning the essentials.