我正在GCP VM实例上运行Django项目,
我的Dockerfile
是:
FROM python:3.5
RUN apt-get update
USER root
WORKDIR /app
ADD . /app
RUN pip install -r requirements.txt
WORKDIR /app/etalentNET
EXPOSE 8000
CMD ["python", "manage.py", "makemigrations"]
CMD ["python", "manage.py", "migrate"]
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
我的doker-compose.yaml
是:
version: '3'
services:
db:
image: sqlite3
web:
build:
image: demo:latest
dockerfile: Dockerfile
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
当我运行docker run -p 8000:8000 demo
时,除了容器没有显示任何内容。
CONTAINER ID IMAGE COMMAND STATUS PORT
ef4585c1e580 demo "python ma…" Up 12 hours 0.0.0.0:8000->8000/tcp
我尝试通过<host_ip>:8000
访问它,但没有ERR_CONNECTION_TIMED_OUT
我正在Ubuntu 16.04
和Django-2.0.6
的GoogleCloud机器上运行。
运行sudo netstat -lp --inet
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 *:ssh *:* LISTEN 1629/sshd
udp 0 0 *:bootpc *:* 967/dhclient
udp 0 0 etalent-net-machine:ntp *:* 1627/ntpd
udp 0 0 localhost:ntp *:* 1627/ntpd