Docker connection refused hanging Django
当我运行容器时,它挂在下一行,如果我写
curl http://0.0.0.0:8000/
我得到
Failed to connect to 0.0.0.0 port 8000: Connection refuse
这是我的码头文件
1 2 3 4 5 6 7 8 9 10 11 | FROM python:3.6.1 # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app ADD . /app RUN pip3 install -r requirements.txt CMD ["python3","dockerizing/manage.py","runserver","0.0.0.0:8000"] |
我也试过通过docker-compose.yml文件来完成它,但还是没有发生任何事情,我搜索了很多,也没有找到解决方案,这就是docker-compose.yml。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | version:"3" services: web: image: app1 deploy: replicas: 5 resources: limits: cpus:"0.1" memory: 50M restart_policy: condition: on-failure ports: -"8000:8000" networks: - webnet networks: webnet: |
顺便说一下,如果我用我的应用程序图像运行Docker PS,我会得到:
1 2 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e9633657f060 app1 "python3 dockerizi..." 5 seconds ago Up 5 seconds friendly_dijkstra |
当我使用django-compose.yml和
1 2 3 4 5 6 7 | `MacBook-Pro-de-Jesus:docker-django Almaral$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 13677a71d9d5 app1:latest "python3 dockerizin..." 15 seconds ago Up 11 seconds getstartedlab_web.1.cq3zqmpfsii5g6m5r9qsnmtb1 c6693118ef70 app1:latest "python3 dockerizin..." 16 seconds ago Up 12 seconds getstartedlab_web.4.r472oh80s4zd1yymj447f1df6 f3822e47970b app1:latest "python3 dockerizin..." 16 seconds ago Up 12 seconds getstartedlab_web.2.lkp43v9h30esjohcnf3pe31hi f66a4038ebdf app1:latest "python3 dockerizin..." 16 seconds ago Up 12 seconds getstartedlab_web.5.xxu01ruebd84tnlxmoymsu0vo e3d31c419c11 app1:latest "python3 dockerizin..." 16 seconds ago Up 13 seconds getstartedlab_web.3.uqswgirmg22sjnekzmf5b4xo7` |
似乎你没有打开的端口。
如果你使用
1 | docker run -p 8000:8000 app1 |
如果你使用
1 | docker-compose up web |
你有
为您的码头组成的配置文件,修改端口重定向从一个