Docker容器中运行的Python UDP服务器
在继续开发之前,我想在Docker中测试一个简单的UDP服务器。我以前从未与Docker合作过,所以我认为这应该是一个初学者的错误 我现在有什么 服务器 码头工人Docker容器中运行的Python UDP服务器,python,docker,udp,Python,Docker,Udp,在继续开发之前,我想在Docker中测试一个简单的UDP服务器。我以前从未与Docker合作过,所以我认为这应该是一个初学者的错误 我现在有什么 服务器 码头工人 # Use an official Python runtime as a base image FROM python:3.7.2-slim # Set the working directory to /app WORKDIR /app # Copy the current directory contents into th
# Use an official Python runtime as a base image
FROM python:3.7.2-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Make port 6071 available outside this container
EXPOSE 6071/udp
# Run app.py when the container launches
CMD ["python", "app.py"]
如何执行容器
我尝试了几种端口使用组合,但在运行它(Windows)时没有看到任何结果
额外:
要测试服务器,我正在使用hercules发送USP数据:
它适用于此配置: 使用dockerfile中的无缓冲输出
CMD ["python","-u","main.py"]
它在码头外工作吗?是的。我已经用pycharm和cmd进行了测试,工作没有问题
docker run --rm -p 6071:6071/udp listener
CMD ["python","-u","main.py"]