Thanks that actually got me where i wanted to get to (with a little more workaround): If I start a docker container like this
docker run -it --rm dockerfile/mongodb bash -c "HOST_IP=`/sbin/ip route|awk '/default/ { print $3 }'` mongo --host $HOST_IP:27017" I get the correct behaviour. I think I should be able to get it going now. Although maybe exposing the slave host ip inside the container may not be a bad idea. -- Ankur > On 27 Oct 2014, at 00:14, Tim Chen <t...@mesosphere.io> wrote: > > Hi Ankur, > > You can't access host via 'localhost' in a docker container since localhost > (127.0.0.1) is just the loopback that is in the container and not to your > host. > However since docker automatically creates the bridge for you that connects > the container and host, you can access the host by it's ip from the container. > > Try the following instead: > HOST_IP=`hostname -i` > docker run -it --rm dockerfile/mongodb bash -c "mongo --host $HOST_IP:27017" > > Tim > > On Sun, Oct 26, 2014 at 11:28 PM, Ankur Chauhan <an...@malloc64.com > <mailto:an...@malloc64.com>> wrote: > Hi Tim, > > Thanks for the reply. > > Yes these are services that are running on all the nodes. Imagine it like > this: All slave hosts have a mongos running on 27017, a kafka broker, etc > always running. I think I just don't know how to access them from within the > container? My perception is that accessing localhost:27017 from within the > container doesn't connect to the hosts' localhost:27017. If that is possible, > how do i do it? I started a mongos on 27017 but when i tried the command > `docker run -it --rm dockerfile/mongodb bash -c 'mongo --host > localhost:27017'` it was unable to connect. > > -- Ankur > >> On 26 Oct 2014, at 21:12, Tim Chen <t...@mesosphere.io >> <mailto:t...@mesosphere.io>> wrote: >> >> Hi Ankur, >> >> Not sure I understand exactly, are these common services all running on the >> same host where you're running the container? >> >> If it's running the same host, docker container should be able to access any >> port in the host, if it's cross hosts then you have to setup your own bridge >> and use the lxc-conf option, or use something like pipework. >> >> I'm adding the lxc-conf options into the next release of mesos. >> >> Tim >> >> On Sun, Oct 26, 2014 at 6:39 PM, Ankur Chauhan <an...@malloc64.com >> <mailto:an...@malloc64.com>> wrote: >> Hi all, >> >> So I have been dabbling with docker containers in and mesos. I have the >> following scenario and i was wondering if someone had experience with >> something like this. >> >> I have a bunch of dockerized apps running and the slave hosts have some >> common services running, something like mongos and kafka brokers etc. I was >> wondering if there was a way to expose these services (i.e. some tcp port) >> to the docker containers? >> >> Is this even a legitimate way of exposing services to apps but my main >> intention is to avoid going over the network or something. >> >> -- Ankur >> > >