Tag:

如何在一个docker容器中运行etcd之后启动一个python脚本?

我build立了一个由python2.7-alpine和etcd( https://hub.docker.com/r/elcolio/etcd/ )组成的docker文件,我试图在etcd运行之后运行一个python脚本(从相同的容器),但是我得到连接错误,因为etcd还没有结束。 有什么build议么? (我试图在上一个CMD之后创build另一个CMD,并且将exec命令放入run.sh) FROM python:2.7-alpine RUN pip install python-etcd # Create script directory RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY ./scripts /usr/src/app ## install etcd RUN apk add –update ca-certificates openssl tar && \ wget https://github.com/coreos/etcd/releases/download/v2.0.10/etcd-v2.0.10-linux-amd64.tar.gz && \ tar xzvf etcd-v2.0.10-linux-amd64.tar.gz && \ mv etcd-v2.0.10-linux-amd64/etcd* /bin/ && \ apk del –purge tar openssl […]

如何重新启动容器内的进程/使用原始的restart.py重新启动PhpStorm

我正在用PhpStorm做一个图像(作为我构build可移植开发环境的一部分)。 除了PhpStorm无法自行重启,一切运行都很顺利。 它使用bin/restart.py脚本,在docker化时不起作用。 这是脚本的身体: #!/usr/bin/env python # Waits for the parent process to terminate, then executes specified commands. import os import signal import sys import time if len(sys.argv) < 3: raise Exception('usage: restart.py <pid> <path> [optional command]') signal.signal(signal.SIGHUP, signal.SIG_IGN) pid = int(sys.argv[1]) while os.getppid() == pid: time.sleep(0.5) // *** if len(sys.argv) > 3: to_launch = […]

ImportError:在重新启动Pod修复程序时,无法在窗格中导入名称<package>

请注意,这不是特定于下面的导入,因为我已经观察到不同的豆荚。 Pod引发导入错误,虽然包显示已成功安装所需的版本。 如果删除并重新创build吊舱,错误消失。 这发生在几个不同包装的豆荚上,重新启动豆荚就消失了。 任何指针为什么我们可能会看到这个问题? 例子:虽然netmiko包安装成功,但我看到下面的导入错误。 from netmiko import ConnectHandler File "/opt/aruba/central/apps/configuration/ENV/local/lib/python2.7/site-packages/netmiko/__init__.py", line 1, in <module> from netmiko.ssh_dispatcher import ConnectHandler File "/opt/aruba/central/apps/configuration/ENV/local/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py", line 21, in <module> from netmiko.ovs import OvsLinuxSSH ImportError: cannot import name OvsLinuxSSH

什么导致这种间歇性的尼克斯build设失败,错误“太多层次的符号链接”?

我为 另一个Nixexpression式中 的Python环境编写了一个Nixexpression式,用于包含我所维护的主要Python软件集合的Docker镜像。 大部分时间构build成功。 有时候,构build失败的可能性并不大,像这样的错误非常多: rsync: readlink_stat("/nix/store/898mvvvdja9a8svkvnyid72gwggjfk92-python-2.7.13-env/lib/python2.7/site-packages/nevow/js/Nevow") failed: Too many levels of symbolic links (40) 据我所知,关于lib/python2.7/site-packages/nevow/js/Nevow一直是一个错误(相对于lib/python2.7/site-packages/nevow/js/Nevow文件和目录中的其他文件或目录)事情)。 观察这些成功和失败的构build环境是numtide/nix-builder Docker镜像。 在travis-ci上可以看到一些版本(当然,这个环节的信息会随着时间而改变)。 存储库中还有一个工具,它应该运行整个构build过程,使得原则上可重复的失败(忽略它们本质上似乎是间歇性的)。

有什么方法可以确保您在stream模式下从docker-py日志逐行读取吗?

我正在使用https://docker-py.readthedocs.io/en/stable/并for line in container.logs(stream=True):读取行的日志for line in container.logs(stream=True):但看起来并不总是完整的一行。 有时我得到部分线路,在下一次迭代中,我得到了整个线路。 有什么方法可以确保在处理之前阅读完整一行吗?

如何使用docker-py创build服务时绑定一个端口?

我想pipe理docker服务自动化。 我必须把一个端口绑定到服务上。 但docker SDK for python中的docker service创build函数不能绑定一个端口。 https://docker-py.readthedocs.io/en/stable/services.html有没有什么方法可以解决这个问题?

将parameter passing给没有-e标志的Docker

我试图复制别人的工作作为学习经验。 他们似乎已经创build了一个Docker容器,可以在没有-e标志的情况下build参数。 我是Docker的新手,我一直在试图弄清楚这是如何工作的。 我一直在玩我的Dockerfile ,它坐在: 1 # Base img 2 FROM python:3-onbuild 3 4 # Run app 5 ENTRYPOINT python ./app.py $1 我想弄清楚如何运行下面的命令 docker run –rm mydocker 42 并让Docker运行以下内容 python ./app.py 42 是否有另一种方式来传递我失踪的论点?

不能build立Dockerfile – :不是目录错误使用ADD命令

我正在尝试为python / flask webapp制作一个dockerfile,并根据我读过的内容多次修改这些问题 我目前的Dockerfile如下: FROM ubuntu:latest #Update OS RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list RUN apt-get update RUN apt-get -y upgrade # Install Python RUN apt-get install -y python-dev python-pip # Add requirements.txt ADD requirements.txt /webapp ADD requirements.txt . # Install uwsgi Python web server RUN pip install uwsgi # Install app requirements RUN […]

PDAL:无法创build“裁剪”types的筛选器阶段

我想在python中使用pdal。 我开始了一个超级简单的裁剪: json = """{ "pipeline":[ "ARRA-LFTNE_NewYork_2010_000636.las", { "type":"crop", "bounds":"([616766.770,617765.46],[4510733.640,4511649.800])" }, "output.laz" ] }""" pipeline = pdal.Pipeline(unicode(json,encoding="utf-8")) pipeline.validate() # check if our JSON and options were good pipeline.loglevel = 8 #really noisy count = pipeline.execute() arrays = pipeline.arrays metadata = pipeline.metadata log = pipeline.log json来自pdal的hp https://www.pdal.io/pipeline.html#pipeline ,应该简单地裁剪图像。 但是,在validation过程中会失败并显示错误: Traceback (most recent call last): File "/src/test.py", […]

如何保持dockerexec_run查询之间的变数?

我正在使用Python的Docker SDK,我想在同一个运行的容器中发送多个python查询,但是我不能在查询之间保留variables。 我使用exec_run每个与python3-c代码也许这不是最好的办法吗? 我们的目标是在使用Flask之后,使用像ipython这样的网页作为交互式shell。 代码如下: import docker client = docker.from_env() container=client.containers.run(image="myimage",command=['/bin/bash'],tty=True,detach=True,volumes=['/data']) code="first_string='first string of text';print('hello world');print(first_string)" a=container.exec_run(['python3','-c',code]) b=container.exec_run(['python3','-c','print(first_string)']) print("Result query A {}".format(a.strip().decode('UTF-8'))) print("Result query B {}".format(b.strip().decode('UTF-8'))) container.stop() 这段代码给了我这个结果,第二个exec_run命令的问题: $ python3 alpha.py result hello world first string of text result Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'first_string' is not […]