You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker镜像无法推送到私有仓库问题求助(Docker 17.03.0-ce)

Fixing "http: server gave HTTP response to HTTPS client" When Pushing to Private HTTP Registry

It looks like you've hit a common configuration gotcha with Docker and insecure HTTP registries on Ubuntu 16.04. Let's break down the problem and fix it step by step.

The Root Cause: Incorrect Config File Name

You mentioned creating a docker.json file in /etc/docker, but Docker on Ubuntu (and most Linux distributions) expects the daemon configuration to be stored in daemon.json, not docker.json. That's almost certainly why your insecure registry setting wasn't being applied, even after restarting the Docker service.

Step-by-Step Resolution

  1. Rename the config file to the correct name
    Run this command to fix the filename mismatch:

    sudo mv /etc/docker/docker.json /etc/docker/daemon.json
    
  2. Validate your config file syntax
    Double-check that your daemon.json has valid JSON (no missing commas or mismatched quotes). It should look exactly like this (replace <hostname> with your actual registry host):

    {
      "insecure-registries": ["<hostname>:5000"]
    }
    
  3. Restart Docker to apply the configuration
    Use either of these commands to restart the Docker service (both work on Ubuntu 16.04):

    sudo /etc/init.d/docker restart
    # Alternatively, use the systemd command
    sudo systemctl restart docker
    
  4. Confirm the config was loaded successfully
    To verify Docker recognizes your insecure registry, run:

    docker info | grep -A 2 "Insecure Registries"
    

    You should see <hostname>:5000 listed under the insecure registries section.

  5. Retry the push command
    Now go ahead and run your push command again:

    docker push <hostname>:5000/<username>/<repository>:<tag>
    

Additional Troubleshooting If It Still Fails

  • If <hostname> is an IP address instead of a domain name, double-check for typos in the insecure-registries entry.
  • Check Docker's log for startup errors that might indicate a problem with the config file:
    cat /var/log/docker.log
    
  • Re-run your curl test (curl http://<hostname>:5000/v2/_catalog) to confirm the registry itself is still reachable via HTTP.

内容的提问来源于stack exchange,提问作者Narcis Neacsu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:17:25