I am trying to run a django application in a docker container. I use uWSGI to serve the django application, and celery running in the background also works. These processes are triggered by the supervisor.
The problem I am facing is that I cannot see the application on the port that I expect to see. I set port 8080 and start the uwsgi process on 8080, but I can not find my application in the browser with the IP address $(boot2docker ip):8080 . I just get Google Chrome "This webpage is not available." (I am using a Mac, so I need to get the boot2docker ip address). The container obviously works and reports that my uwsgi and celery processes also work successfully.
When I run docker exec CONTAINER_ID curl localhost:8080 , I get a response like
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 21 0 21 0 0 3150 0 --:--:-- --:--:-- --:--:-- 3500
... therefore it seems that the container is accepting connections on port 8080.
When I run docker exec CONTAINER_ID netstat -lpn |grep :8080 , I get tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 11/uwsgi
When I run docker inspect CONTAINER_ID , I get the following:
[{ "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": {} } ]
As someone is not very good at Docker, Iโm not quite sure what this all means. Maybe there is a clue why I canโt connect to my server?
Here is my Docker file, so you can see if I am doing something obviously wrong.
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"]