Dan*_*ubb 1 python docker docker-compose
我编写了几个 Python 脚本来回测交易策略。我正在尝试通过 docker compose 部署这些。
馈送容器将测试文件复制到工作目录,回测器容器将在工作目录中拾取并处理它们。然后,处理后的测试文件被发送到“已完成的工作”文件夹。然后,回测器输出的一些 CSV 文件会写入另一台计算机上的 NFS 共享。我应该提到的是,这一切都在 Ubuntu 20.04 上运行。
据我所知,一切都应该正常工作,但由于某种原因,“docker-compose up”命令挂在“附加到”上。应该有带有 print 语句的进一步输出(我已经取消缓冲 Dockerfile,因此这些应该会显示出来)。我还让它运行了一段时间,看看是否有任何东西正在处理,看起来容器从未启动过。我已经查看了处理此问题的所有其他线程,但尚未找到可以解决此问题的解决方案。
任何见解都非常非常感谢。谢谢。
这是 docker-compose 文件:
version: '3.4'
services:
feeder:
image: feeder
build:
context: .
dockerfile: ./Dockerfile.feeder
volumes:
- /home/danny/io:/var/lib/io
worker1:
image: backtester
build:
context: .
dockerfile: ./Dockerfile
volumes:
- /home/danny/io/input/workers/worker1:/var/lib/io/input
- /home/danny/io/input/completedwork:/var/lib/io/archive
- /nfs/tests:/var/lib/tests
worker2:
image: backtester
build:
context: .
dockerfile: ./Dockerfile
volumes:
- /home/danny/io/input/workers/worker2:/var/lib/io/input
- /home/danny/io/input/completedwork:/var/lib/io/archive
- /nfs/tests:/var/lib/tests
worker3:
image: backtester
build:
context: .
dockerfile: ./Dockerfile
volumes:
- /home/danny/io/input/workers/worker3:/var/lib/io/input
- /home/danny/io/input/completedwork:/var/lib/io/archive
- /nfs/tests:/var/lib/tests
Run Code Online (Sandbox Code Playgroud)
这是回测器的 Dockerfile:
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim-buster
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY . /app
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
# RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
# USER appuser
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "backtester5.py"]
Run Code Online (Sandbox Code Playgroud)
这是 feeder 的 Dockerfile:
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.8-slim-buster
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY . /app
# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
# RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
# USER appuser
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "feeder.py"]
Run Code Online (Sandbox Code Playgroud)
这是显示的最后一条消息:
Attaching to project4_feeder_1, project4_worker1_1, project4_worker2_1, project4_worker3_1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2014 次 |
| 最近记录: |