Muhammed Imran Hussain

LAMP/LEMP, MEAN, JAVA Developer

CURL response is empty; API server running on Docker container

My API endpoint (for example http://localhost:3000) server running on Docker container. Initiated curl session in PHP (vagrant box) and the response was empty. Here is the code sample without proxy.

I then read docker networking docs and solved my problem setting docker ip as curl proxy. Here are the steps:

Step 1: Find your docker ip
1. Find your container ID:

2. Grab your docker ip by container ID:

Here is the final PHP code example:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.