dockerized nginx“超时”几分钟后

我有nginx运行在docker容器使用股票nginx图像。 它是代理运行django应用程序的gunicorn。

最后一次连接5秒后,我看到一些“客户端172.18.64.88closureskeepalive连接”。 然后,如果我等待5分钟或更长时间,则客户端上首次尝试连接错误。 如果我立即点击Firefox默认的连接问题的“再试一次”button,它会连接。

我目前使用docker 1.90rc1和nginx 1.9.5

nginx -V nginx version: nginx/1.9.5 built by gcc 4.9.2 (Debian 4.9.2-10) built with OpenSSL 1.0.1k 8 Jan 2015 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6 

我也经历了很多docker挂起。 Docker会经常挂断几分钟或更长的时间,以至于我不得不重启这个盒子。 目前不完全确定如何debugging。

以下是对nginx容器的检查:

 [ { "Id": "01ceb09884dae63e13e663d43e6b35115c23cae0e02a4bff8c75e039971f6a5f", "Created": "2015-10-28T16:25:52.885407197Z", "Path": "nginx", "Args": [ "-g", "daemon off;" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 19594, "ExitCode": 0, "Error": "", "StartedAt": "2015-10-28T16:25:55.559977049Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "5c82215b03d10884d98e0c074a69881e7428484c47855d49863233297f86fd9a", "NetworkSettings": { "Bridge": "", "EndpointID": "", "SandboxID": "7a4a6f275d49f438f4e3cffbce72328bab65f22dc5648e430b93c83e24a60489", "Gateway": "172.17.42.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "HairpinMode": false, "IPAddress": "172.17.0.3", "IPPrefixLen": 16, "IPv6Gateway": "", "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:03", "Networks": [ "bridge" ], "Ports": { "443/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "443" } ], "80/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "80" } ] }, "SandboxKey": "/var/run/docker/netns/7a4a6f275d49", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null }, "ResolvConfPath": "/var/lib/docker/containers/01ceb09884dae63e13e663d43e6b35115c23cae0e02a4bff8c75e039971f6a5f/resolv.conf", "HostnamePath": "/var/lib/docker/containers/01ceb09884dae63e13e663d43e6b35115c23cae0e02a4bff8c75e039971f6a5f/hostname", "HostsPath": "/var/lib/docker/containers/01ceb09884dae63e13e663d43e6b35115c23cae0e02a4bff8c75e039971f6a5f/hosts", "LogPath": "/var/lib/docker/containers/01ceb09884dae63e13e663d43e6b35115c23cae0e02a4bff8c75e039971f6a5f/01ceb09884dae63e13e663d43e6b35115c23cae0e02a4bff8c75e039971f6a5f-json.log", "Name": "/docker_nginx_1", "RestartCount": 0, "Driver": "btrfs", "ExecDriver": "native-0.2", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": null, "HostConfig": { "Binds": [ "/usr/local/docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro", "/usr/local/docker/nginx/logs:/var/log/nginx/log:rw", "/usr/local/docker/nginx/ssl:/nginx/ssl:ro", "/usr/local/docker/virtualenvs/lss/src/cisco/static:/static:ro", "/usr/local/docker/virtualenvs/lss/src/cisco/media:/media:rw" ], "ContainerIDFile": "", "LxcConf": null, "Memory": 0, "MemoryReservation": 0, "MemorySwap": 0, "KernelMemory": 0, "CpuShares": 0, "CpuPeriod": 0, "CpusetCpus": "", "CpusetMems": "", "CpuQuota": 0, "BlkioWeight": 0, "OomKillDisable": false, "MemorySwappiness": null, "Privileged": false, "PortBindings": { "443/tcp": [ { "HostIp": "", "HostPort": "443" } ], "80/tcp": [ { "HostIp": "", "HostPort": "80" } ] }, "Links": [ "/docker_web_1:/docker_nginx_1/docker_web_1", "/docker_web_1:/docker_nginx_1/web", "/docker_web_1:/docker_nginx_1/web_1" ], "PublishAllPorts": false, "Dns": null, "DnsOptions": null, "DnsSearch": null, "ExtraHosts": [], "VolumesFrom": [], "Devices": null, "NetworkMode": "default", "IpcMode": "", "PidMode": "", "UTSMode": "", "CapAdd": null, "CapDrop": null, "GroupAdd": null, "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, "SecurityOpt": null, "ReadonlyRootfs": false, "Ulimits": null, "LogConfig": { "Type": "json-file", "Config": {} }, "CgroupParent": "", "ConsoleSize": [ 0, 0 ], "VolumeDriver": "" }, "GraphDriver": { "Name": "btrfs", "Data": null }, "Mounts": [ { "Name": "1492af30f865754d65f67357d67e9d6b039df0be0c905c3387bca7e0e28fd47a", "Source": "/var/lib/docker/volumes/1492af30f865754d65f67357d67e9d6b039df0be0c905c3387bca7e0e28fd47a/_data", "Destination": "/var/cache/nginx", "Driver": "local", "Mode": "", "RW": true }, { "Source": "/usr/local/docker/nginx/nginx.conf", "Destination": "/etc/nginx/nginx.conf", "Mode": "ro", "RW": false }, { "Source": "/usr/local/docker/nginx/logs", "Destination": "/var/log/nginx/log", "Mode": "rw", "RW": true }, { "Source": "/usr/local/docker/nginx/ssl", "Destination": "/nginx/ssl", "Mode": "ro", "RW": false }, { "Source": "/usr/local/docker/virtualenvs/lss/src/cisco/static", "Destination": "/static", "Mode": "ro", "RW": false }, { "Source": "/usr/local/docker/virtualenvs/lss/src/cisco/media", "Destination": "/media", "Mode": "rw", "RW": true } ], "Config": { "Hostname": "01ceb09884da", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "443/tcp": {}, "80/tcp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "VIRTUAL_HOST=pttlvl1", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "NGINX_VERSION=1.9.5-1~jessie" ], "Cmd": [ "nginx", "-g", "daemon off;" ], "Image": "nginx", "Volumes": { "/etc/nginx/nginx.conf": {}, "/media": {}, "/nginx/ssl": {}, "/static": {}, "/var/cache/nginx": {}, "/var/log/nginx/log": {} }, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": { "com.docker.compose.config-hash": "f1ce82828ce42bdf943575acbf5ac7cb9b46607c0202d0d49008928766b671e9", "com.docker.compose.container-number": "1", "com.docker.compose.oneoff": "False", "com.docker.compose.project": "docker", "com.docker.compose.service": "nginx", "com.docker.compose.version": "1.5.0rc1" } } } ]