【问题标题】:shared volume with luigi docker server与 luigi docker 服务器共享卷
【发布时间】:2019-10-05 12:09:12
【问题描述】:

我正在尝试使用 docker 和 luigi https://hub.docker.com/r/spotify/luigi 进行一些试验

我用 spotify/luigi 创建了一个 docker 容器。我对此很陌生,并且似乎无法通过控制台访问此图像。

我创建了一个共享卷并将其映射到容器的 /luigi/share/

import luigi
import time

class HelloWorld(luigi.Task):
    def requires(self):
        return None
    def output(self):
        return luigi.LocalTarget('/luigi/share/helloworld3.txt')
    def run(self):
        time.sleep(1)
        with self.output().open('w') as outfile:
            outfile.write('Hello World!\n')
        time.sleep(1)

class NameSubstituter(luigi.Task):
    name = luigi.Parameter()

    def requires(self):
        return HelloWorld()
    def output(self):
        return luigi.LocalTarget(self.input().path + '.name_' + self.name)
    def run(self):
        time.sleep(1)
        with self.input().open() as infile, self.output().open('w') as outfile:
            text = infile.read()
            text = text.replace('World', self.name)
            outfile.write(text)
        time.sleep(1)

if __name__ == '__main__':
    luigi.run()

这是我使用 python test.py --scheduler-host 192.168.178.48 NameSubstituter 运行的示例代码

当我现在查看另一个具有共享卷的容器时,没有创建任何文本文件。

我有点迷路了……

提前谢谢你

【问题讨论】:

    标签: python docker luigi


    【解决方案1】:

    当你直接从 Python 运行 test.py 时,你实际上并没有通过 docker 运行任何东西。您需要按照说明实际设置您的容器,并在其中使用 test.py,然后从 docker 运行它。此链接可能包含更多信息:How to run my python script on docker?

    【讨论】:

      猜你喜欢
      • 2018-05-21
      • 1970-01-01
      • 1970-01-01
      • 2019-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多