stuartpb / dokku-bind-port

Dokku plugin for binding app container ports to host interfaces
MIT License
16 stars 3 forks source link

Unable to redeploy when once bound #5

Closed algas closed 9 years ago

algas commented 10 years ago

I was using this plugin on dokku-alt server. After I bound a port with an docker app container, I was not able to rebuild or redeploy without unbounding the port.

$ sudo dokku bind:create app-name 12345 12345
$ sudo dokku rebuild app-name
...
Error response from daemon: Cannot start container (container_id): Bind for 0.0.0.0:12345 failed: port is already allocated

What am I supposed to do?

stuartpb commented 10 years ago

I think dokku-alt has that "seamless deployment" patch that makes it so it doesn't stop the old version before it starts the new version, so there's nothing you can do, except switch to vanilla Dokku (which I think incorporated the same patch recently?) or unbind/rebind the port when you redeploy, as you mentioned.

Basically, in dokku-alt (and contrary to how Dokku upstream worked when I wrote this), when you rebuild the app, the old version keeps running (until it's finished serving all incoming requests to it and the new version is ready) while the new version starts up. During that window, you can't have both versions bound to the port at the same time, so the attempt to start the new version fails.

(Side note, you can just do sudo dokku bind:create app-name 12345 rather than specify 12345 twice, as the value of CONTAINER_PORT is the default value of HOST_PORT.)

In general, in terms of maintenance of this plugin, for the record, I kind of agree with #2 that it's better to use a straight docker-options plugin than this specific one (although that still wouldn't help in this case).

Anyway, I'm focusing my efforts on Plushu instead of Dokku now. If I ever implement dokku-alt style failover deployment in Plushu, since it causes issues like this, it'll be optional (either as a config variable or as a separate plugin altogether).

stuartpb commented 10 years ago

If you were to write a patch that makes this compatible, you'd have to change the docker-opts hook to a post-deploy hook that restarts the app container with the bind option, which kind of defeats the entire purpose of the failover patch in the first place.

algas commented 10 years ago

Thank you for your comment. I understand that it is not easy to write a patch for this problem. I'll try to use the docker-options plugin.

stuartpb commented 9 years ago

Closed by deprecation. If you want a platform that can bind app ports, use Plushu.