apparatus / fuge-runner

Process and container runner and watcher for the fuge tool
MIT License
4 stars 19 forks source link

No port is exposed on host for some containers #50

Open vjgn opened 4 years ago

vjgn commented 4 years ago

I have a case where when I use docker run with "-p 1080:1080" then port 1080 is exposed and accessible from host. But when I configure the same container in fuge and run, that port is not exposed. Below is my fuge config for this service: worker1: image: dsworker:123.71 type: container environment:

When i do docker ps, it does not show any ports exposed. As mentioned before, executing docker run with -p shows the port correctly in docker ps command.

After going through the docker api for create container, looks like the ExposedPorts command is at the config level and not under HostConfig. When I changed this from (in dockerRunner.js):

var createOpts = {Image: container.image,
  Tty: false,
  HostConfig: {
    ExposedPorts: ep,
    PortBindings: pb
  }
}

to

var createOpts = {Image: container.image,
  Tty: false,
  HostConfig: {
    ExposedPorts: ep,
    PortBindings: pb
  },
  **ExposedPorts: ep**
}

Then the port is correctly getting exposed on the host and I can access my service. Is this a bug in fuge runner?

I found further that the docker file used to generate the container does not EXPOSE this port 1080. We are working to have that fixed. But still, when docker run can work correctly, fuge should also work. I think the fix above addresses this use-case.