3

I am running the latest docker for mac build and have a number of docker-compose based apps up and running - all accepting being called from my local network.

I am now trying to implement a node.js app that needs network access to scan the host's network as well as responding to port 5005.

Can anyone show me a docker-compose.yml file that would allow for the following networking:

Local network: 192.168.123/24 router 192.168.123.1

Docker for Mac is running on my macbook at 192.168.123.118

Inside my network http://192.168.123.118:5005 should respond to the node requests to the container.

The container needs to scan the local network to look for services.

I have tried combinations of default, bridge and host networks with one or two interfaces and have only gotten confused.

Can a container truly be part of the host network?

I seem to remember that this was achievable when running docker on virtualbox.

The actual code I'm trying to configure is https://github.com/jishi/node-sonos-http-api I don't think there are issues with the code, just the environment I am trying to create.

The project I am trying to run is the Sonos controller app:

Here are my Dockerfile and docker-compose.yml files and the command to build the Sonos controller app

mkdir sonos 
cd sonos 
git clone https://github.com/jishi/node-sonos-http-api sonos 

docker-compse.yml

version: '2'
  services:
    sonos:
      build: sonos
      network_mode: host

sonos/Dockerfile

FROM node:4-onbuild
EXPOSE 5005 

After this I can start the controller:

docker-compose stop; docker-compose-build; docker-compose up;

And the output is:

Recreating sonos_sonos_1
Attaching to sonos_sonos_1
sonos_1  | npm info it worked if it ends with ok
sonos_1  | npm info using npm@2.15.11
sonos_1  | npm info using node@v4.6.2
sonos_1  | npm info prestart sonos-http-api@1.1.7
sonos_1  | npm info start sonos-http-api@1.1.7
sonos_1  | 
sonos_1  | > sonos-http-api@1.1.7 start /usr/src/app
sonos_1  | > node server.js
sonos_1  | 
sonos_1  | 2016-11-13T11:19:52.476Z INFO Presets loaded: { example: 
sonos_1  |    { players: 
sonos_1  |       [ { roomName: 'Bathroom', volume: 10 },
sonos_1  |         { roomName: 'Kitchen', volume: 10 },
sonos_1  |         { roomName: 'Office', volume: 10 },
sonos_1  |         { roomName: 'Bedroom', volume: 10 },
sonos_1  |         { roomName: 'TV Room', volume: 15 } ],
sonos_1  |      playMode: { shuffle: true, repeat: 'all', crossfade: false },
sonos_1  |      pauseOthers: false,
sonos_1  |      favorite: 'My example favorite' } }
sonos_1  | 2016-11-13T11:19:52.497Z INFO http server listening on port 5005
sonos_1  | 2016-11-13T11:20:18.478Z ERROR No system has yet been discovered. Please see https://github.com/jishi/node-sonos-http-api/issues/77 if it doesn't resolve itself in a few seconds.

The final line is in response to this request: http://localhost:5005/zones

I feel that the sonos container running in host mode is not able to see my local network in order to discover my Sonos speakers.

nwinkler
  • 52,665
  • 21
  • 154
  • 168
SteveGroom
  • 129
  • 1
  • 15

0 Answers0