我在Windows 10上使用Docker Toolbox。
我正在使用python manage.py runserver 0.0.0.0:8000
我收到了回复Starting development server at http://0.0.0.0:8000/
但是当我在浏览器中访问http://127.0.0.1:8000/
时,它无效。
有什么想法吗?我该怎么检查?
我尝试过docker run -p 8000:8000 my_image
,但我得到了Bind for 0.0.0.0:8000 failed: port is already allocated.
这是我的docker-compose.yml文件:
version: '2'
services:
postgres:
image: postgres
restart: on-failure
redis:
image: redis:alpine
restart: on-failure
elasticsearch:
image: "elasticsearch:2.4-alpine"
restart: on-failure
ports:
- "9200:9200"
politikon:
image: *****
links:
- postgres
- redis
- elasticsearch
ports:
- "2233:22"
- "8000:8000"
dns:
- 8.8.8.8
- 8.8.4.4
environment:
- "POSTGRES_PORT_5432_TCP_PORT=5432"
- "POSTGRES_PORT_5432_TCP_ADDR=postgres"
- "DJANGO_SETTINGS_MODULE=*****.settings.dev"
- "BONSAI_URL=http://elasticsearch:9200/"
- "ELASTIC_USERNAME=*****"
- "ELASTIC_PASSWORD=*****"
volumes:
- $PWD:/app
restart: on-failure
这是我的Docker文件(没有一些不相关的行):
FROM ubuntu:trusty
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y -qq --fix-missing
RUN apt-get install -y wget
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RUN apt-get update -y -qq --fix-missing
RUN apt-get upgrade -y -qq
RUN apt-get install -y python-dev python-pip postgresql-client-common postgresql postgresql-contrib postgresql-9.5 libpq-dev git libmemcached-dev curl openssh-server mercurial gettext vim libjpeg-dev libjpeg8-dev
RUN echo "locale-gen en_US.UTF-8" >> /etc/profile
RUN echo "dpkg-reconfigure locales" >> /etc/profile
RUN echo "export VISIBLE=now" >> /etc/profile
RUN echo "KexAlgorithms=diffie-hellman-group1-sha1" >> /etc/ssh/sshd_config
RUN echo "PermitUserEnvironment=yes" >> /etc/ssh/sshd_config
ENV PORT 8000
EXPOSE 8000
EXPOSE 22
RUN touch /root/.bash_profile
RUN echo "cd /app" >> /root/.bash_profile
RUN mkdir /root/.ssh/
RUN touch /root/.ssh/environment
CMD env >> /root/.ssh/environment; export -p | grep _ >> /etc/profile; /usr/sbin/sshd -D;
ADD /requirements.txt /app/
WORKDIR /app
RUN apt-get install zlib1g-dev
RUN pip install -r requirements.txt
CMD tail -f LICENSE