Docker Community Forums

Share and learn in the Docker community.

Yes, another annoying question about bridge and webservices


(Redsandev) #1

Hi All, are you fine? Because in the next few words I will repeat a “famous” question:

Why apache/laravel server configuration needs a 0.0.0.0 for localhost when I run their container in a docker-machine?

Any times I get up a docker-machine, any container I will set it needs a specific IP configuration in apache/laravel config-file.

So, let me show you a little shell-stuff

1) Jump in!
I have a docker-machine driver=virtualbox, with a specific IP address (192.168.99.100:2376) and inside i put a container with
docker run -ti --name=FunnyBunny debian
2) Install common-stuff
I just followed Laravel-wiki to install laravel or, for apache machine I choose a digitalocean tutorial: please this is not any kind of adv-strategy: Google shows these!
3) let’s start!
For laravel I need to use (ok, port is not the real problem)

php artisan serve --localhost=0.0.0.0 --port=8080

And as the same way for apache, I need to configure file

/etc/apache2/apache2.conf

modify ServerName to

ServerName 0.0.0.0

And, in the end, modify ports.conf in

/etc/apache2/ports.conf

and modify Listen in that way

Listen 0.0.0.0:80

So, I’m sure to give more details that you need, but the point still here: Why I need to add ip 0.0.0.0 for these kinds of services, when put the same container out docker-machine (just run docker without eval-command) I don’t need to do them?

Thank you so much!


(Sam) #2

apache needs to configure a tcp/ip listen for incoming traffic.

the listen takes 2 parms
ip address (in case u have multiple) and port

if you don’t CARE what ip address to use (you only have one, or the default is ok), then u code 0.0.0.0
note that 0.0.0.0 is different than 127.0.0.1 (which will ONLY be listening INSIDE this box. )