-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First time deploys port mappings mess up after reboot #82
Comments
Good catch, great info. Turns out Docker will not use the same ports when it's told to automatically restart containers when it restarts. It works on your second deploy because we basically manually restart the container with the right port. One option, as you said, is to rebuild the Nginx configs when docker restarts. Another option is to turn off automatic restart of containers when docker restarts and manually start them. The latter sounds more appropriate, but to me that makes it sound like a deficiency in docker (If we have to turn a useful feature off to do it right). I'll poke around the Docker community and see how they feel. |
Yeah. I've been scratching my head about this too. Seems kind of silly. Let me know what you find. I've been asking around IRC and the mailing list too as it seems to be a pretty fundamental problem. If docker is for building a PaaS then having the ports stay after a reboot would have to be pretty fundamental I would have thought? |
Have you guys considered using the IP addresses of the containers directly instead of using the docker port mapping feature? I have found the pattern to work quite well in situations like this: reverse proxy on the host (in another container, even, potentially), talking to pre-determined ports on the IP of containers -- easily exposed with docker inspect on the container ID. Since the containers are on the same subnet in the same bridge, they can easily talk between themselves. You only really have to re-map the reverse proxy container, if any! |
@fujin That's a great idea. Seems a lot simpler. However, the same issue occurs. The IP addresses of the containers change on reboot unfortunately. Seems like the only way to go is to set all this stuff up on reboot unless the docker guys weigh in with a better alternative. |
I've created a PR #88 that should address this issue that takes the nginx rewriting approach. |
I've created an alternative solution relying on a central port registry that fixes this issue too. It's in PR #94 |
There's another problem with the nginx configuration template file which is imho the cause of the error. Solved w/ pull request #95 |
👍 just ran into the exact same problem here. |
Yeah. I've put in 2 PRs which I've been using in production now for about a month that solve the problem.
Either PR will fix the issue. In a real PaaS there would be a routing layer such as hipache to manage the routing, so maintaining any port mappings is less important. @progrium has been saying that he'll chat to the docker guys to work out the best solution to this for dokku. |
Thanks @eugeneware, should I just apply one of those PRs and follow the standard upgrade procedure? |
@amaltson Yes. Though some of the changes affect the upstart scripts that get generated. If there's not too many deploys then it might be simpler to just do a fresh install. The main file you need to create and run is the dokku.conf upstart script. See the diff to see what it changes. Yell out if you have any problems. |
I posted about this on the docker mailing list after having a chat on irc with @shykes from the docker team. Feel free to chime in: https://groups.google.com/forum/#!topic/docker-user/Py3YHb1C8Jo. |
Thanks @asm89 I've put in my $0.02! It sounds like on the face of it, from Solomon's response, that the only real reliable way to deal with the reboot issue is to use the docker API and reallocate ports (e.g. the approach in #88). That even if they try to keep the same ports after reboot (which would be nice!), that there is still the possibility with reconfiguration, or another service coming up before docker can grab the port - that the port mapping may not stick. |
Flynn is working on a service discovery component that should help with On Thu, Aug 15, 2013 at 8:50 PM, Eugene Ware notifications@github.comwrote:
Jeff Lindsay |
Tagged the issue as "enhancement" for now. It should be improved when the service discovery component of flynn can be pulled in. |
Fixing possible port conflicts between containers, sleep after nginx reload.
Redeploy apps on reboot, fixes dokku#82
When I deploy a new application and reboot the docker container restarts on another port so all the nginx mappings fail and the app can't be accessed.
Steps to reproduce:
You'll either the a
502 bad gateway
error, or the wrong app (if the port got mapped to another app).Here's an audit trail after I pushed a new app
nodetest2
.After I initially pushed it, here's what the
docker ps
returned:Notice that it was listening on port 49160.
And
cat
ing the CONTAINER and PORT entries in the /home/git/nodetest2 did:Looking at the config.json for the docker container gives:
Everything is working and set to map to port
49160
.When I reboot, however, this is what
docker ps
shows:See how the port has now been mapped to
49153
. Therefore the nginx port forwarding won't work and the app is inaccessible.Checking the docker container file once again:
And the port has changed to
49153
.I'm not sure what the solution is as my knowledge of docker is limited. You could rewrite the nginx conf file after reboot...
Strangely enough, however, when you do a SECOND push, then the whole thing works as it's not mapping to port 5000, and the port mappings stay correct the second push.
Not sure what the answer is.
The text was updated successfully, but these errors were encountered: