August 12, 2017

When Localhost isn't the Local Host

Let's see what happens when we try to ping localhost from within our PHP container.

We cover a small gotcha that could waste your time.


If your code (e.g. php/php-fpm) is executed on a separate container as your web server (e.g. nginx), then pinging localhost as an HTTP request wont' work, because there's no web server listening for HTTP requests within your code (php) container!

Use the hostname of your Nginx/web server container instead, e.g. http://nginx instead of http://localhost.

Looking for a deeper dive into Docker?

Sign up here to get a preview of the Shipping Docker course! Learn how to integrate Docker into your applications and develop a workflow to make using Docker a breeze!

All Topics