So on my host environment I have this tomcat service running on port 10000 so I can access the office internal services.
I have a windows hosts entry:
localhost developer.mycompany.com
So I can access the endpoint developer.mycompany.com:10000/some/url
and if successful return a json response.
I also have a Docker compose file that has spun up nginx and php-fpm containers and linked them to run a linux based PHP development environment.
What I am trying to achieve is to make the docker container(s) aware of the developer.mycomoany.com
host entry. So when my PHP code on my linke containers sends a POST request to http://developer.mycompany.com:10000/some/url
it knows about the host entry and is able to hit that end point.
I have tried the config net=host
but that doesn't work with linked containers.
PHP app error message:
{"result":{"success":false,"message":"Error creating resource: [message] fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known [file] /srv/http/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php [line] 282 [message] fopen(http://developer.mycompany.com:10000/app/register): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known [file] /srv/http/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php [line] 282"}}
How do I enable my PHP app on my linked containers to talk to the host developer.mycompany.com
(localhost) entry?
Here is my docker-compose:
app:
image: linxlad/docker-php-fpm
tty: true
ports:
- "9000:9000"
volumes:
- ./logs/php-fpm:/var/log/php-fpm
- ~/Development/Apps/php-hello-world:/srv/http
web:
image: linxlad/docker-nginx
ports:
- "8080:80"
volumes:
- ./conf/nginx:/etc/nginx/conf.d
- ./logs/nginx:/var/log/nginx
- ~/Development/Apps/php-hello-world:/srv/http
links:
- app
Edits:
Her is my ifconfig output from docker machine.
Thanks
I found the IP of my docker machine and used that in my hosts nginx proxy config like such which then redirected it to the nginx location config in my docker container.
Host nginx:
location /apps/myapp/appversion {
proxy_pass http://192.168.99.100:8080;
}
Docker Nginx container config:
location /apps/myapp/appversion {
try_files $uri $uri/ /index.php?args;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php last;
}
}