Tag:

当build立docker图像时,pip版本失败

我试图从我的python应用程序创build一个docker镜像,但是在尝试安装时收到有关我的pip版本的错误消息: Collecting tensorflow==1.2.1 (from -r requirements.txt (line 20)) Could not find a version that satisfies the requirement tensorflow==1.2.1 (from -r requirements.txt (line 20)) (from versions: ) No matching distribution found for tensorflow==1.2.1 (from -r requirements.txt (line 20)) You are using pip version 7.1.2, however version 9.0.1 is available. You should consider upgrading via the 'pip […]

Py-Docker使用远程卷的create_container

我正在使用pydocker库远程运行docker容器。 我需要在正在运行的容器中安装一个本地目录。 文档确实提到了使用API​​创build卷的方式。 但是,我无法弄清楚如何在创build容器时使用该卷。 我正在按照https://docker-py.readthedocs.io/en/stable/api.html#module-docker.api.container

Docker中的Python:如何在主机上保存一个简单的Python文件

我上周开始与Docker合作。 我使用http.client和http.server在Python 3.6.2中编写了http客户机和服务器程序。 服务器端运行在Ubuntu 16.04下的云中的Docker容器中; 客户端在本地运行。 作为testing的一部分,我将一个文件从本地机器发送到云中的服务器,在到达服务器时获取文件内容,将文件内容写入服务器上的文件,并显示文件内容在PuTTYterminal中逐行显示,以确认文件在服务器上正确接收(这个简单的练习只是一个testing)。 虽然文件内容正确显示,并且没有收到任何错误消息,但新文件( \home\pythonwebapp\HTTP_File_Received )不会显示在主机上的工作目录\home\pythonwebapp\ ,而且我无法在任何其他可能的位置。 这是相关的代码: class HTTPServTest_RequestHandler(BaseHTTPRequestHandler): # POST def do_POST(self): # Send response status code self.send_response(200) # Send headers self.send_header('Content-type','text/html') self.end_headers() varLen = int(self.headers['Content-Length']) data_received = self.rfile.read(varLen) # WRITE POST DATA TO FILE fname = r'\home\pythonwebapp\HTTP_File_Received' fi = open(fname, "w") for line in data_received: fi.write(str(line)) print(line) print(" […]

应用程序抱怨它无法看到mqtt服务器

我运行一个群(目前只有一个Pi),我开始2个服务。 一个mqtt服务器,(它的工作,已经testing了!) – 另一个python应用程序,订阅mqtt服务,然后发布事件到mqtt服务器。 因此,一个堆栈,2个服务。 我有2个Dockerfiles预制图像,和一个Docker-Compose.yaml(v3)文件,启动这两个服务(1-mqtt,2-python应用程序与mqtt客户端)。 python应用程序抱怨它无法看到mqtt服务器。 我不确定这两个服务之间的networking是如何工作的。 任何build议指出我在正确的方向? 我试过链接 – 但看到它是一个V2function,现在不推荐使用。 这里是Docker-Compose: Docker-compose.yaml的堆栈 version: "3" services: mosquitto: image: iotplay/iotplay_mqtt deploy: resources: limits: cpus: '0.15' memory: 140M reservations: cpus: '0.06' memory: 85M replicas: 1 restart_policy: condition: on-failure delay: 30s max_attempts: 1 volumes: – /home/pi/data/stack_rhome/rh_mqtt/config:/mqtt/config/ – /home/pi/data/stack_rhome/rh_mqtt/data:/mqtt/data/ – /home/pi/data/stack_rhome/rh_mqtt/log:/mqtt/log/ – /etc/localtime:/etc/localtime:ro – /etc/timezone:/etc/timezone:ro ports: – 1878:1883 […]

卷上的Python Docker API错误使用“悬挂”filter进行修剪

我正在使用“悬挂”filtertesting在卷上使用修剪的代码 我的代码块: self._client.volumes.prune(filters={'dangling': True}) 并导致docker守护进程的DockerAPI错误请求错误: docker.errors.APIError: 400 Client Error: Bad Request ("Invalid filter 'dangling'") 它在我的队友机器上运行良好,我相信这是我的错误。 你能指点我吗? Client: Version: 17.09.0-ce API version: 1.32 Go version: go1.8.3 Git commit: afdb6d4 Built: Tue Sep 26 22:42:18 2017 OS/Arch: linux/amd64 Server: Version: 17.09.0-ce API version: 1.32 (minimum version 1.12) Go version: go1.8.3 Git commit: afdb6d4 Built: Tue Sep 26 […]

用Python SDK创buildDocker容器并在其中执行命令

我正在尝试使用Docker Python SDK创build一个Docker容器,并继续执行一些命令并获得一些结果。 我发现在文档中,我可以运行容器执行一个命令,然后这个容器不见了 import docker client = docker.from_env() client.containers.run('alpine', 'echo hello world') 或创build一个容器并使其作为守护进程运行 container = client.containers.run('bfirsh/reticulate-splines', detach=True) 但我仍然不知道如何保持容器运行,并发送命令执行,这可能吗? 还是我错过了什么? 还是我误解了一些东西?

为什么我的Docker正在运行,但是Http没有被服务?

我最近从https://www.docker.com/products/docker-toolbox安装DockerToolbox并安装。 我testing了它,并根据快速testingdocker运行你好,世界运作良好。 现在学习如何按照https://docs.docker.com/get-started/part2/一步一步地使用它,首先我创build了一个Docker镜像: docker build -t friendlyhello . 然后我检查构build的图像: $ docker images 运行应用程序,将我的机器的端口4000映射到容器的已发布端口80,使用-p: docker run -p 4000:80 friendlyhello 问题是当我在浏览器中inputurl时,应用程序没有按预期的方式被提供服务。 HTTP://本地主机:4000 即使当我从壳中curl,我也不明白: 我将不胜感激关于如何解决问题的任何想法。

在Docker中运行Linux Alpine 3.6的M2Crypto ImportError

尝试在Linux Alpine 3.6上使用时遇到M2Crypto ImportError。 想知道是否有人遇到过这个问题,以及他们是否可以对这种情况如何发生以及他们如何解决问题有所了解。 任何帮助将不胜感激,谢谢! 重现步骤: #Dockerfile FROM alpine:3.6 RUN apk update RUN apk add python2 python2-dev py-pip RUN apk add ca-certificates \ cyrus-sasl-dev \ gcc \ libffi-dev \ libmemcached-dev \ libxml2-dev \ musl-dev \ openssl \ postgresql-dev \ linux-headers \ wget \ xmlsec \ xmlsec-dev RUN pip install M2Crypto==0.25.1 从那里,使用以下命令构build并运行容器: docker build -t […]

把python-pip放在CentOS的docker镜像上?

我想要一个有pip的Docker镜像,然后在Dockerfile中使用pip来安装Python需求。 现在,我的Dockerfile看起来像这样: FROM centos # Set the working directory to /app WORKDIR /app # Copy the current directory contents into the container at /app ADD . /app # Set up pip RUN rm -f /var/lib/rpm/__* RUN rpm –rebuilddb -v -v RUN yum -y install epel-release && yum clean all RUN yum -y install python-pip && […]

Python:使用Docker而不是Virtualenv

为了在Ubuntu服务器上托pipePython服务器,我使用了Docker和Alpine Linux容器。 有没有办法不使用容器内的Alpine Linux,而是使用scratch来代替? 这对于容器意味着什么呢,它会看到整个操作系统/文件系统,而且它写入FS的任何改变实际上都被写入了Docker容器,不知怎的, Sandboxie会这样做吗? 如果我然后安装新的Python包,他们只会被写入容器。 如果我做一个安装,它也只是写入容器?