【问题标题】:Docker pull fails behind ApacheDocker pull 在 Apache 后面失败
【发布时间】:2020-03-20 12:20:24
【问题描述】:

我有一个自定义 Docker 注册表,可通过 http://localhost:5000 访问

这是 Apache 配置:

Listen 443
<VirtualHost *:443>
    ServerName registry.mycompany.com

    SSLEngine on
    SSLCertificateFile    ...
    SSLCertificateKeyFile ...
    SSLCACertificateFile  /etc/pki/tls/certs/thawte.pem

    ProxyPreserveHost On
    ProxyPass         / http://localhost:5000/
    ProxyPassReverse  / http://localhost:5000/
    ProxyRequests     Off
</VirtualHost>

这里是我如何启动注册表:

docker run -d \
    -p 5000:5000 \
    -e REGISTRY_STORAGE_DELETE_ENABLED=true \
    -e REGISTRY_AUTH=htpasswd \
    -e REGISTRY_AUTH_HTPASSWD_REALM="Registro" \
    -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
    --restart=always \
    --name registro \
    registry:2

一切正常(docker pull,...),但 docker push 失败。在此处重试后显示错误消息:

first path segment in URL cannot contain colon

相关文档可以在这里找到:

【问题讨论】:

  • 您是否尝试在您的 apache 配置中将 localhost 更改为 127.0.0.1?
  • 你到底在使用什么推送命令?您是否尝试过不使用代理(进行测试)?
  • 请使用这个文件,看看它是否适合你github.com/azurecr-test/distribution-uaenorth/blob/…
  • 感谢@cagta,但将 localhost 更改为 127.0.0.1 并没有改变。
  • @PierreB.失败的命令是docker push registry.mycompany.com/myimage:mytag

标签: apache docker proxy


【解决方案1】:

使用 docker compose,我使用图像 jwilder/nginx-proxy:alpine 作为代理,效果更好

version: "3.7"
services:
  registry:
    image: registry:2
    expose:
    - 5000
    volumes:
    - "./registry.yaml:/etc/docker/registry/config.yml"
    - "./img:/var/lib/registry"
    - "./certs:/certs"
    - "./auth:/auth"
    environment:
      VIRTUAL_HOST: registry.company.com
    restart: always
  gui:
    image: joxit/docker-registry-ui:static
    environment:
      URL: https://registry.company.com
      REGISTRY_TITLE: Company Docker registry
      DELETE_IMAGES: "true"
      VIRTUAL_HOST: gui-registry.company.com
      #HTTPS_METHOD: nohttps
    expose:
    - 80
  proxy:
    image: jwilder/nginx-proxy:alpine
    ports:
      - 80:80
      - 443:443
    volumes:
    - "/var/run/docker.sock:/tmp/docker.sock:ro"
    - "./certs:/etc/nginx/certs"
    - "./registry.conf:/etc/nginx/vhost.d/registro.fccma.com"
    - "./cors.conf:/etc/nginx/vhost.d/registro.fccma.com_location"
    environment:
      DEFAULT_HOST: registro.fccma.com

通过这种方式,我可以在同一主机上拥有 Docker 注册表及其对应的 GUI。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 1970-01-01
    • 2020-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-22
    相关资源
    最近更新 更多