Quick Start
First distinguish three paths: fresh installation of Docker Engine, replacing the Docker CE package repository, and configuring only the Registry Mirror. The three have different scopes of impact; do not conflate "installation source" and "image pull acceleration".
Ready to use:
- "Plan Docker Engine installation and verification for Rocky Linux 9; do not execute yet."
- "Docker is already installed; only use LinuxMirrors to replace the Registry Mirror."
- "Safely merge multiple registry-mirrors into the existing daemon.json, and provide rollback steps."
Read-only check of Docker status:
docker version 2>/dev/null || true
Check the current Mirror without modifying the configuration:
docker info 2>/dev/null | sed -n '/Registry Mirrors/,+5p'
Check Compose V2:
docker compose version 2>/dev/null || true
When to use
Use when the user wants to install Docker Engine, replace the Docker CE package repository, configure a Registry Mirror, or troubleshoot docker.sh/--only-registry . Not applicable to general system software sources, Docker Desktop, or containerd/Kubernetes global mirror configuration.
Intended users
- Beginners: first distinguish the three modes of fresh installation, CE repository, and Registry.
- Operations personnel: focus on protecting the repo, daemon.json, service status, and container data.
- Platform engineers: use explicit versions, pinned script commits, batch verification, and rollback gates.
Prerequisites
Must know the distribution, version, architecture, whether Docker is already installed, the init system, the existing daemon.json, and maintenance authorization.
How to use
Step 1: Pre-check
Read thepre-check checklistto confirm the distribution, version, architecture, root, Docker status, init system, and existing configuration.
Step 2: Choose a path
Fresh installation/repair CE repository/--only-registry choose one of the three; refer toMode differences。
Step 3: Define parameters
From theparameter referenceselect the source, Registry, version, and language parameters.
Step 4: Protect the current state
Back up /etc/docker/daemon.json and the Docker CE repo files, and record the current Docker version and service status.
Step 5: Confirm before executing
Show the scope of impact; by default do not disable the firewall, and do not run directly on an unknown production machine.
Step 6: Verify
Check the repo,docker version, service status,docker info Registry Mirrors, and actual pulling.
Step 7: Roll back
Follow therollback guideto restore the JSON/repo backups and restart or restore the original service state.
Capability boundaries and inapplicable scenarios
✅ Good at handling
- Planning for Docker Engine installation and Docker CE repository source replacement on Debian-based and Red Hat-based Linux.
- For systems with Docker already installed,
--only-registry, single/multiple Registry Mirrors, anddaemon.jsonmerging. - Specified versions, internal network sources, service verification, failure troubleshooting, and configuration rollback.
⚠️ Conditions required
- Actual installation requires root, a supported distribution, network, a maintenance window, and an available package manager.
- Specify
--designated-versionYou need to first query the complete version actually provided by the repository. - Existing
daemon.jsonwhen it contains proxies, logging drivers, private registries, and other configurations, a JSON-level merge must be performed rather than overwriting.
❌ Out of scope (provide alternatives)
- Docker Desktop, Windows, or macOS → use Docker Desktop official settings and enterprise policies.
- Rootless Docker, standalone distributions without a compatible package manager → refer to Docker official binary or rootless documentation.
- Kubernetes/containerd global image configuration → use the corresponding runtime and cluster configuration process; do not change only Docker.
Documentation Routing
- Complete options: readparameter reference。
- Support scope: readcompatibility。
- Three working modes: readmode differences。
- Main script and Lite: readscript selection。
- Before running: readpre-check checklist。
- Safe JSON merge: readdaemon.json guide。
- Restore configuration: readrollback guide。
- Error troubleshooting: readtroubleshooting。
Security and Privacy
This skill does not collect or upload user data, and does not require host passwords, SSH private keys, or Registry credentials. Review remote scripts before running them. The firewall is retained by default; only discuss --close-firewall truewhen the user explicitly authorizes it and understands the exposure surface. Do not overwrite unknown daemon.json, and do not write private Registry credentials into examples.
Rules
- Do not confuse Docker CE software sources with Registry Mirror.
- Do not fabricate installation versions, repository paths, image addresses, or verification results.
- By default, do not disable the firewall, do not overwrite the existing daemon.json, and do not delete container data.
- If the service fails to start, first verify the JSON and logs, then decide whether to restore the backup.
When information is insufficient
First provide a safe example based on "Docker already installed, only replace Registry, systemd, retain existing daemon.json, do not disable the firewall, only generate a plan." Please supplement: distribution and version, architecture, whether Docker is already installed, whether the target is a CE software source or Registry, init system, existing daemon.json, and whether there is a private registry or proxy.
Verification Checklist
- Has the installation, CE repository, or Registry-only path been explicitly selected?
- Does the parameter exist in the current
DockerInstallation.sh --help? daemon.jsonHas it first passedjq/JSON parsing validation and been backed up?- Is the firewall kept unchanged by default?
- Are the service status,
docker info, and actual pull verified at the same time?
Gotchas
- The Docker CE software source determines package downloads, and the Registry Mirror determines image pulls; the two are not interchangeable.
--only-registryWhen Docker Engine cannot be detected, it will exit and cannot be used as an installation command.- Directly rewriting
daemon.jsonwill lose existing configurations such as logging, proxy, and data-root; they must be merged. - Registry Mirror being reachable does not mean the Docker CE software repository is reachable, and vice versa.
--close-firewall trueIt affects the host security boundary and must not be used as a default "installation optimization."- Specifying a version only writes
28.0.0may still be affected by the distribution's package version format; query the repository list first.
FAQ
Q1: What if I only want to accelerate image pulls? When Docker is already installed, use --only-registry, and specify one or more addresses via --source-registry .
Q2: How do I write multiple addresses? Separate them with English commas, and validate each address; the order represents attempt priority, not automatic speed testing.
Q3: Does Compose need to be installed separately? The current script integrates the Docker Compose V2 plugin, using docker compose, and should not by default rely on the old docker-compose。
Q4: How do I confirm the Mirror is in effect? docker info Check Registry Mirrors, then pull a small public image and observe errors and elapsed time.
Q5: Can daemon.json be overwritten? Only when you have confirmed the file does not exist or its contents can be fully replaced; by default it should be parsed, merged, validated, and backed up.
Q6: Does the script support all Linux? The Docker script mainly targets Debian-based and Red Hat-based systems and their derivatives; independent distributions should switch to the official installation method.