Docker Port Forwarding
我正试图在Docker容器中运行我的Django应用程序。我使用uwsgi为django应用程序提供服务,并且有一个芹菜工人在后台运行。这些过程由主管启动。
我遇到的问题是,我无法在希望看到它的端口上看到应用程序。我正在暴露端口8080并在8080上运行uwsgi进程,但在IP地址
当我运行
1 2 3 | % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 21 0 21 0 0 3150 0 --:--:-- --:--:-- --:--:-- 3500 |
…因此,集装箱似乎接受8080端口的连接。
当我运行
当我运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | [{ "AppArmorProfile":"", "Args": [ "-c", "/home/docker/code/supervisor-app.conf" ], "Config": { "AttachStderr": true, "AttachStdin": false, "AttachStdout": true, "Cmd": [ "supervisord", "-c", "/home/docker/code/supervisor-app.conf" ], "CpuShares": 0, "Cpuset":"", "Domainname":"", "Entrypoint": null, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "env=staging" ], "ExposedPorts": { "8080/tcp": {} }, "Hostname":"21443d8a16df", "Image":"vitru", "Memory": 0, "MemorySwap": 0, "NetworkDisabled": false, "OnBuild": null, "OpenStdin": false, "PortSpecs": null, "StdinOnce": false, "Tty": false, "User":"", "Volumes": null, "WorkingDir":"" }, "Created":"2014-12-27T01:00:22.390065668Z", "Driver":"aufs", "ExecDriver":"native-0.2", "HostConfig": { "Binds": null, "CapAdd": null, "CapDrop": null, "ContainerIDFile":"", "Devices": [], "Dns": null, "DnsSearch": null, "ExtraHosts": null, "Links": null, "LxcConf": [], "NetworkMode":"bridge", "PortBindings": {}, "Privileged": false, "PublishAllPorts": false, "RestartPolicy": { "MaximumRetryCount": 0, "Name":"" }, "SecurityOpt": null, "VolumesFrom": null }, "HostnamePath":"/mnt/sda1/var/lib/docker/containers/21443d8a16df8e2911ae66d5d31341728d76ae080e068a5bb1dd48863febb607/hostname", "HostsPath":"/mnt/sda1/var/lib/docker/containers/21443d8a16df8e2911ae66d5d31341728d76ae080e068a5bb1dd48863febb607/hosts", "Id":"21443d8a16df8e2911ae66d5d31341728d76ae080e068a5bb1dd48863febb607", "Image":"de52fbada520519793e348b60b608f7db514eef7fd436df4542710184c1ecb7f", "MountLabel":"", "Name":"/suspicious_fermat", "NetworkSettings": { "Bridge":"docker0", "Gateway":"172.17.42.1", "IPAddress":"172.17.0.87", "IPPrefixLen": 16, "MacAddress":"02:42:ac:11:00:57", "PortMapping": null, "Ports": { "8080/tcp": null } }, "Path":"supervisord", "ProcessLabel":"", "ResolvConfPath":"/mnt/sda1/var/lib/docker/containers/21443d8a16df8e2911ae66d5d31341728d76ae080e068a5bb1dd48863febb607/resolv.conf", "State": { "ExitCode": 0, "FinishedAt":"0001-01-01T00:00:00Z", "Paused": false, "Pid": 16230, "Restarting": false, "Running": true, "StartedAt":"2014-12-27T01:00:22.661588847Z" }, "Volumes": {}, "VolumesRW": {} } ] |
作为一个对Docker不太流利的人,我真的不知道这意味着什么。也许这里有一条线索可以解释为什么我不能连接到我的服务器?
这是我的档案,所以你可以看看我在里面是否做了什么公然错误的事情。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | FROM ubuntu:14.04 # Get most recent apt-get RUN apt-get -y update # Install python and other tools RUN apt-get install -y tar git curl nano wget dialog net-tools build-essential RUN apt-get install -y python3 python3-dev python-distribute RUN apt-get install -y nginx supervisor # Get Python3 version of pip RUN apt-get -y install python3-setuptools RUN easy_install3 pip RUN pip install uwsgi RUN apt-get install -y python-software-properties # Install GEOS RUN apt-get -y install binutils libproj-dev gdal-bin # Install node.js RUN apt-get install -y nodejs npm # Install postgresql dependencies RUN apt-get update && \ apt-get install -y postgresql libpq-dev && \ rm -rf /var/lib/apt/lists # Install pylibmc dependencies RUN apt-get update RUN apt-get install -y libmemcached-dev zlib1g-dev libssl-dev ADD . /home/docker/code # Setup config files RUN ln -s /home/docker/code/supervisor-app.conf /etc/supervisor/conf.d/ # Create virtualenv and run pip install RUN pip install -r /home/docker/code/vitru/requirements.txt # Create directory for logs RUN mkdir -p /var/logs # Set environment as staging ENV env staging EXPOSE 8080 # The supervisor conf file starts uwsgi on port 8080 and starts a celeryd worker CMD ["supervisord","-c","/home/docker/code/supervisor-app.conf"] |
我相信你的问题是,
您需要通过
如果使用的话,fig.yml文件中的