简体   繁体   English

Docker与urwid(ncurses)Python应用程序组合

[英]Docker-compose with urwid (ncurses) Python app

I am creating an algorithm that needs to run on a server, along with a small database. 我正在创建一个需要在服务器以及小型数据库上运行的算法。

docker-compose.yml: 泊坞窗,compose.yml:

version: '3'
services:
  app:
    command: python -u app.py
    build: .
    stdin_open: true
  db:
    image: mongo:latest

Dockerfile: Dockerfile:

FROM python:3.6.1

COPY . /usr/src/app

WORKDIR /usr/src/app

RUN pip install -r requirements.txt

The app is an ncurses (urwid) app which transforms the terminal into a TUI to monitor the algorithm. 该应用程序是ncurses(urwid)应用程序,可将终端转换为TUI以监控算法。 When I run the app separately on my laptop, it works as expected with the terminal turning into the TUI. 当我在笔记本电脑上单独运行该应用程序时,它可以按预期运行,并且终端变成了TUI。 When ran with the command "docker-compose up", the terminal first shows stdout from docker and mongo, after which certain (clipped) parts of the TUI start to show. 当使用命令“ docker-compose up”运行时,终端首先显示来自docker和mongo的stdout,然后开始显示TUI的某些(剪切)部分。 The TUI components are malformed and unresponsive. TUI组件格式错误且无响应。 Killing the docker process keeps the clipped parts in the terminal. 终止docker进程会将剪切的部分保留在终端中。

Possible hint : The TUI contains a running clock with hrs:min:sec. 可能的提示 :TUI包含运行时间为hrs:min:sec的时钟。 When the clipped parts appear the clock is correct but it freezes immediately. 出现被修剪的部分时,时钟是正确的,但会立即冻结。 The clock is updated by an underlying asyncio event loop. 时钟由基础异步事件循环更新。

This works for me: 这对我有用:

docker-compose.yml 泊坞窗,compose.yml

version: '3'
services:
  app_db:
    container_name: appDB
    image: mongo:latest

  app:
    command: python -u /usr/src/app/app.py
    container_name: app
    build: .
    links:
    - app_db
    stdin_open: true
    tty: true

When running docker-compose run app , both the app and the mongo container are running and I get a terminal interface into the app container. 当运行docker-compose run app时 ,该应用程序和mongo容器都在运行,并且我在应用程序容器中获得了一个终端接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM