我有一个运行django项目的本地docker镜像正在运行。 docker镜像已启动,但当我转到设置了端口8000的本地主机时,会显示the page is not working
和127.0.0.1 didn’t send any data
的消息。
这是泊坞代码:
omars-mbp:Split omarjandali$ docker build -t split .
Sending build context to Docker daemon 222.2kB
Step 1/7 : FROM python:3
---> 79e1dc9af1c1
Step 2/7 : WORKDIR user
---> 15e014da5b80
Removing intermediate container f4081817276f
Step 3/7 : COPY requirements.txt ./
---> 1f444390862b
Step 4/7 : EXPOSE 8000
---> Running in f75a6674ade2
---> 7641865ffc85
Removing intermediate container f75a6674ade2
Step 5/7 : RUN pip install -r requirements.txt
---> Running in 40738a20f481
Collecting Django==1.11.5 (from -r requirements.txt (line 1))
Downloading Django-1.11.5-py2.py3-none-any.whl (6.9MB)
Collecting gunicorn==19.6.0 (from -r requirements.txt (line 2))
Downloading gunicorn-19.6.0-py2.py3-none-any.whl (114kB)
Collecting pytz (from Django==1.11.5->-r requirements.txt (line 1))
Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
Installing collected packages: pytz, Django, gunicorn
Successfully installed Django-1.11.5 gunicorn-19.6.0 pytz-2017.3
---> 371a95617f78
Removing intermediate container 40738a20f481
Step 6/7 : COPY . .
---> fa31f9520063
Step 7/7 : CMD python manage.py runserver 0.0.0.0:8000
---> Running in 28b6a097dac4
---> c0d19bca8c2d
Removing intermediate container 28b6a097dac4
Successfully built c0d19bca8c2d
Successfully tagged split:latest
omars-mbp:Split omarjandali$ docker run -d -p 8000:8000 split
d70035b14ab0c2046f2bfc8418960a0b1e5dd8bb75e09a045b41e94bcb097aa4
omars-mbp:Split omarjandali$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d70035b14ab0 split "python manage.py ..." 4 seconds ago Up 2 seconds 0.0.0.0:8000->8000/tcp focused_shirley
docker file:
FROM python:3
WORKDIR user
COPY requirements.txt ./
EXPOSE 8000
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]