问题原文
原帖链接 · MikiBelavista · CC BY-SA 3.0
I have build my small Python(flask ) app.Container is here docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4146fd976547 identidock_identidock:latest "/cmd.sh" 5 minutes ago Up 5 minutes 9090/tcp, 9191/tcp agitated_leakey
If I try
curl localhost:5000
curl: (7) Failed to connect to localhost port 5000: Connection refused
I have checked sudo netstat -an | grep -E "5000" unix 3 [ ] STREAM CONNECTED 25000
It is not listeting on 5000. yaml line with ports
ports:
- "5000:5000"
If I exec my container
docker exec -it agitated_leakey /bin/bash
uwsgi@4146fd976547:/app$ netstat -ln
bash: netstat: command not found
My Dockerfile
RUN pip install Flask==0.10.1 uWSGI==2.0.8
WORKDIR /app
COPY app /app
COPY cmd.sh /
EXPOSE 9090 9191
Why this happens?
已采纳解答
原帖链接 · user490221 · CC BY-SA 4.0
An alternative issue can be with the mode. In the publish section I had to set the mode explicitly to host and everything worked:
docker service create --name registry --publish published=5000,target=5000,mode=host registry:2
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
