Tag:

文件作为Docker python应用程序的命令行参数

我需要创builddockerized python应用程序,将从命令行读取文件。 我不知道是否有可能,但我运行这个应用程序的规范是: docker run -t myimage file.csv 目前我的docker文件看起来像这样: FROM python:3 ADD test.py / ENTRYPOINT ["python", "test.py"] CMD ["test.py"] 其中test.py是:import sys def main(args): for a in args: print(a) with open(a, 'r') as f: for l in f: print(l) if __name__ == '__main__': main(sys.argv)

ImportError:导入Docker SDK for Python时,没有名为ssl_match_hostname的模块

为了使用Python的Docker SDK ,我试图在Python脚本中import docker ,但是导致了一个ImportError和下面的跟踪: Traceback (most recent call last): File "/home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils/docker_utils.py", line 1, in <module> import docker File "/home/kurt/.local/lib/python2.7/site-packages/docker/__init__.py", line 6, in <module> from .client import Client, AutoVersionClient, from_env # flake8: noqa File "/home/kurt/.local/lib/python2.7/site-packages/docker/client.py", line 11, in <module> from . import api File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in <module> from .build import BuildApiMixin File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/build.py", […]

以编程方式获取docker统计信息

我正在使用docker-py并试图获得docker统计信息。 但是我无法获得任何API来返回特定容器的统计信息。 有没有一个REST API或任何其他方式来编程获取统计信息? >>> cli = docker.Client(base_url="tcp://xxxxx:2375", version='1.21') >>> cli.containers() >> gives the right o/p >>> cli.containers.get() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'function' object has no attribute 'get' >>> docker.version '1.10.6'

负载平衡docker群

我有一个Docker群模式与一个HAProxy容器,和3个Python Web应用程序。 带HAProxy的容器是公开端口80,并应负载平衡我的应用程序的3个容器(由leastconn )。 这是我docker-compose.yml文件: version: '3' services: scraper-node: image: scraper ports: – 5000 volumes: – /profiles:/profiles command: > bash -c " cd src; gunicorn src.interface:app \ –bind=0.0.0.0:5000 \ –workers=1 \ –threads=1 \ –timeout 500 \ –log-level=debug \ " environment: – SERVICE_PORTS=5000 deploy: replicas: 3 update_config: parallelism: 5 delay: 10s restart_policy: condition: on-failure max_attempts: 3 […]

Google容器引擎公开服务“网站无法访问”

我正在使用Flask,Docker和Google Container Engine构build一个简单的Web应用程序。 我已经指定了以下DockerFile: # Use an official Python runtime as a base image FROM python:2.7-slim # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app ADD . /app # Install any needed packages specified in requirements.txt RUN pip install -r requirements.txt # Make port […]

如何使用Dockerfile从pip获取mod_wsgi-express

我不记得我是如何安装mod_wsgi-express的,但是我几乎可以肯定我使用了pip 。 我在我的requirements.txt文件中有这行:mod_wsgi-express == 4.5.15 Collecting mod_wsgi-express==4.5.15 (from -r /usr/src/app/requirements.txt (line 16)) Could not find a version that satisfies the requirement mod_wsgi-express==4.5.15 (from -r /usr/src/app/requirements.txt (line 16)) (from versions: ) No matching distribution found for mod_wsgi-express==4.5.15 (from -r /usr/src/app/requirements.txt (line 16)) You are using pip version 9.0.0, however version 9.0.1 is available. You should consider […]

什么是定义自定义Travis作业的一种理智的方法?

目前,Travis-ci根本不支持多种语言或自定义作业。 我知道我可以在before_install钩子中安装第二种语言。 让我解释一下我的场景: 我有一个Python包,我目前unit testing通过与多种Python版本的language: python Python。 现在我想添加一个额外的Job,它使用docker来构build和运行一个容器来构buildPython包作为debian包。 一种select是只为每个工作做,但这会显着减慢testing时间。 因此,我想避免这种情况。 另一个select是在travis的构buildmatrix中使用set中的环境variables,并检查一个envvariables是否被设置,如果这样做,我会运行docker集成testing。 这两个选项都显得相当糟糕,而且很冒险。 因此,将这样一个自定义作业添加到我的Travis构buildmatrix中的一种理智的方法是什么?

在Docker Container中安装pip时出错

所以我试图通过首先复制安装文件来在Docker容器中下载pip docker cp get-pip.py dock:get-pip.py 然后我走进集装箱 docker执行官 – 这是58 bash 然后我试图pythonget-pip.py文件,我得到以下错误。 在连接被“NewConnectionError(':build立一个新的连接失败:[Errno -3]临时失败的名称parsing',)中断连接后重试(重试(总= 4,连接=无,读=无,redirect=无) ':/ simple / pip /

在Docker中运行的Python / Flask中运行Vision API演示时的StatusCode.UNAUTHENTICATED

我已经按照Vision API的Google Client Libraries页面的说明开始使用Python中的Vision API(我正在运行2.7)。 由于我的代码在Docker(一个Flask应用程序)中运行,我按照以下方式按照说明操作: 将google-cloud-vision和google-cloud库添加到我的requirements.txt文件中。 创build了一个json帐户凭证文件,并将该文件的位置设置为名为GOOGLE_APPLICATION_CREDENTIALS的环境variables 成功运行gcloud init,同时“ssh”进入我的Web应用程序的泊坞窗容器 将上面链接中的客户端库示例完全复制到testing视图中以运行代码 上面的步骤导致下面的错误: > RetryError: GaxError(Exception occurred in retry method that was not > classified as transient, caused by <_Rendezvous of RPC that terminated > with (StatusCode.UNAUTHENTICATED, Traceback (most recent call last): > File "src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi", > line 154, in grpc._cython.cygrpc.plugin_get_metadata > (src/python/grpcio/grpc/_cython/cygrpc.c:7054) File > "/usr/local/lib/python2.7/site-packages/grpc/_plugin_wrapping.py", > […]

无法在Docker上运行Web应用程序

我有一个简单的Python程序,执行以下操作 identitydock.py from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello Docker!\n' if __name__ == '__main__': app.run(debug=True, host='0.0.0.0') 我的Dockerfile如下 Dockerfile FROM python:3.4 RUN groupadd -r uwsgi && useradd -r -g uwsgi uwsgi RUN pip install Flask==0.10.1 uWSGI==2.0.8 WORKDIR /app COPY app /app COPY cmd.sh / EXPOSE 9090 9191 USER uwsgi CMD ["/cmd.sh"] […]