Hm, I am not sure if I understood you correctly, but let me give you an common example.
You have two docker container running. One for
nginx and another for
nginx image will
runyou’ll have to link both using their names…
docker run -d -n my_php <your-php-image>
docker run -d -p 80:80 -n my_nginx --link my_php <your-nginx-image>
What this does:
Both docker images are prepared to expose ports to the “outer” world. Why “outer”: well as you can see in the
runstatement, only the webserver maps his ports to the hosts port, and so (if your firewall is set properly) to the real “outer” world. The
php-container only expose this to the host and “inner” network (the docker subnet).
The magic is happening in
--link my_php of the webserver …This will create an entry in
/etc/hosts with the name given in
-n my_php and than it will send all incoming requests (*.php) to port 9000 of
my_php if you set this up in
/etc/nginx/nginx.confor any vhost-config.