Docker镜像无法推送到私有仓库问题求助(Docker 17.03.0-ce)
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
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.jsonValidate your config file syntax
Double-check that yourdaemon.jsonhas 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"] }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 dockerConfirm the config was loaded successfully
To verify Docker recognizes your insecure registry, run:docker info | grep -A 2 "Insecure Registries"You should see
<hostname>:5000listed under the insecure registries section.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 theinsecure-registriesentry. - 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

