私有docker注册表和python
我无法使用python中的私有docker注册表。似乎没有读取环境配置 主要步骤和错误 在私有docker注册表和python,docker,docker-registry,Docker,Docker Registry,我无法使用python中的私有docker注册表。似乎没有读取环境配置 主要步骤和错误 在/etc/docker/registries.yaml中,我将私有注册表定义为 mirrors: "192.168.2.62:5055": endpoint: - "http://192.168.2.62:5055" 然而,当我执行 import docker client = docker.from_env() image_tag = "192.168.2.62:5055/do
/etc/docker/registries.yaml中,我将私有注册表定义为
mirrors:
"192.168.2.62:5055":
endpoint:
- "http://192.168.2.62:5055"
然而,当我执行
import docker
client = docker.from_env()
image_tag = "192.168.2.62:5055/dockertest:latest"
for line in client.images.push(repository=image_tag, stream=True, decode=True):
if 'error' in line and line['error']:
print(line['error'])
我收到了错误信息
Get https://192.168.2.62:5055/v2/: http: server gave HTTP response to HTTPS client
用于复制示例:
(您需要编辑本地机器IP的IP)
我使用docker compose在docker容器中启动了私有注册表
version: '3'
services:
registry:
image: registry:2
ports:
- 192.168.2.62:5055:5000
接下来,我定义了docker文件
%%writefile /tmp/docker_test/Dockerfile
FROM alpine:3.7
CMD ["echo","HELLO WORLD"]
并使用
import docker
client = docker.from_env()
image, logs = client.images.build(dockerfile = "Dockerfile",
path = "/tmp/docker_test",
tag = "192.168.2.62:5055/dockertest")
print(image)
print(logs)
for l in logs:
print(l)
registries.yaml
是Kubernetes提供的注册表配置。尤其是k3s
。要重新配置本地docker,需要重新配置/etc/docker/daemon.json
,并添加以下行
{ "insecure-registries":["localhost:5055","192.168.2.62:5055"] }