我在docker中运行了一个用python3编写的服务器,但是我无法正确获得回复,为什么?
服务器代码:
import socket
s = socket.socket()
s.bind(("0.0.0.0",10000))
s.listen(5)
while True:
cur, add = s.accept()
cur.sendall(b"hello")
cur.close()
docker-compose.yml:
version: '2'
services:
python:
build:
context: .
dockerfile: python_Dockerfile
ports:
- "10000:10000"
python_Dockerfile:
FROM python:3
WORKDIR /app
RUN mkdir /app/data
COPY test.py /app
CMD ["python", "-u", "test.py"]