[英]docker-compose up not forwarding port
I have the following files. 我有以下文件。 When I run docker-compose up -d and exec into the docker container, I am able to run http://127.0.0.1:5000 and get back results. 当我在docker容器中运行docker-compose up -d和exec时,我能够运行http://127.0.0.1:5000并返回结果。 From the host I get back: 从主持人我得到:
user@ubuntu:~/projects/grip/glm-plotter$ curl -v http://localhost:5000
* Rebuilt URL to: http://localhost:5000/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 5000 (#0)
> GET / HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.58.0
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
If I run the docker-compose command without a -d, it starts up but from a separate terminal I also get back empty results. 如果运行不带-d的docker-compose命令,它将启动,但从另一个终端我也将返回空结果。
docker ps (When running without -d) docker ps(不带-d运行时)
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
237b0a7f8710 glm-plotter_web "python3 glm-plotter…" 16 minutes ago Up 24 seconds 0.0.0.0:5000->5000/tcp glm-plotter_web_1
I'm not sure if the process should be listed under "docker-proxy": 我不确定该进程是否应列在“ docker-proxy”下:
user@ubuntu:~$ sudo netstat -tulpn | grep 5000
tcp6 0 0 :::5000 :::* `LISTEN 13785/docker-proxy`
Dockerfile Dockerfile
FROM library/python:3.6-stretch
RUN apt-get update && apt-get install -y python3
RUN apt-get install -y python3-pip
RUN apt-get install -y build-essential
COPY requirements.txt /
RUN pip3 install --trusted-host pypi.org -r /requirements.txt
RUN pip3 install --upgrade numpy
ADD ./glm-plotter /code
WORKDIR /code
RUN ls .
CMD ["python3", "glm-plotter.py"]
docker-compose.yml 泊坞窗,compose.yml
version: "3"
services:
web:
volumes:
- ~/.aws:/root/.aws
build: .
ports:
- "5000:5000"
Your glm-plotter.py
is listening only on the localhost
in the container. 您的glm-plotter.py
仅在容器中的localhost
上侦听。 Your app must be listening on all interfaces in the container - TCP host 0.0.0.0
, not just locahost/127.0.0.1
- you need to fix your python code. 您的应用必须监听容器中的所有接口-TCP主机0.0.0.0
,而不仅仅是locahost/127.0.0.1
您需要修复python代码。
It is a common issue - flask example: flask is working inside container but not when I port forward it 这是一个常见的问题-烧瓶示例: 烧瓶在容器内工作,但在我将其转发时不起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.