这是indexloc提供的服务,不要输入任何密码
Skip to content

First time deploys port mappings mess up after reboot #82

@eugeneware

Description

@eugeneware

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:

  1. Push a brand new repo to dokku
  2. Reboot the machine
  3. Try to access the app.

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:

ID                  IMAGE                       COMMAND                CREATED             STATUS              PORTS               SIZE
3c6858a2eab4        app/nodetest2:latest        /bin/bash -c /start    38 seconds ago      Up 23 seconds       49160->5000         16.39 kB (virtual 985.9 MB)

Notice that it was listening on port 49160.

And cating the CONTAINER and PORT entries in the /home/git/nodetest2 did:

root@euge:/home/git/nodetest2# cat CONTAINER
3c6858a2eab4
root@euge:/home/git/nodetest2# cat PORT
49160
root@euge:/home/git/nodetest2# cat nginx.conf
upstream nodetest2 { server 127.0.0.1:49160; }
server {
  listen      80;
  server_name nodetest2.euge.co;
  location    / {
    proxy_pass  http://nodetest2;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
  }
}

Looking at the config.json for the docker container gives:

{"ID":"3c6858a2eab44bac6bcd17e09d2749fd2fbe59289efcb981ac289308721851fb","Created":"2013-07-07T10:58:45.651908068Z","Path":"/bin/bash","Args":["-c","/start web"],"Config":{"Hostname":"3c6858a2eab4","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":["5000"],"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PORT=5000"],"Cmd":["/bin/bash","-c","/start web"],"Dns":null,"Image":"app/nodetest2","Volumes":{},"VolumesFrom":""},"State":{"Running":true,"Pid":3111,"ExitCode":0,"StartedAt":"2013-07-07T10:58:45.733151021Z","Ghost":false},"Image":"cb67ce2218ffc55c9e9ba52c7413246b0697edebcba01f63fdab3123a868ee74","NetworkSettings":{"IPAddress":"172.16.42.12","IPPrefixLen":24,"Gateway":"172.16.42.1","Bridge":"docker0","PortMapping":{"5000":"49160"}},"SysInitPath":"/usr/bin/docker","ResolvConfPath":"/etc/resolv.conf","Volumes":{}}

Everything is working and set to map to port 49160.

When I reboot, however, this is what docker ps shows:

ID                  IMAGE                       COMMAND                CREATED             STATUS              PORTS               SIZE
3c6858a2eab4        app/nodetest2:latest        /bin/bash -c /start    11 minutes ago      Up 11 seconds       49153->5000         16.39 kB (virtual 985.9 MB)

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:

{"ID":"3c6858a2eab44bac6bcd17e09d2749fd2fbe59289efcb981ac289308721851fb","Created":"2013-07-07T10:58:45.651908068Z","Path":"/bin/bash","Args":["-c","/start web"],"Config":{"Hostname":"3c6858a2eab4","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":["5000"],"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PORT=5000"],"Cmd":["/bin/bash","-c","/start web"],"Dns":null,"Image":"app/nodetest2","Volumes":{},"VolumesFrom":""},"State":{"Running":true,"Pid":1029,"ExitCode":0,"StartedAt":"2013-07-07T11:09:05.82098963Z","Ghost":false},"Image":"cb67ce2218ffc55c9e9ba52c7413246b0697edebcba01f63fdab3123a868ee74","NetworkSettings":{"IPAddress":"172.16.42.3","IPPrefixLen":24,"Gateway":"172.16.42.1","Bridge":"docker0","PortMapping":{"5000":"49153"}},"SysInitPath":"/usr/bin/docker","ResolvConfPath":"/etc/resolv.conf","Volumes":{}}

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions