diff --git a/docs/assets/images/icon/custom/docker-desktop.svg b/docs/assets/images/icon/custom/docker-desktop.svg new file mode 100644 index 0000000..3763f0f --- /dev/null +++ b/docs/assets/images/icon/custom/docker-desktop.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/assets/images/icon/custom/gitcode.svg b/docs/assets/images/icon/custom/gitcode.svg deleted file mode 100644 index aa9dfdc..0000000 --- a/docs/assets/images/icon/custom/gitcode.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/docs/other/example.md b/docs/other/example1.md similarity index 76% rename from docs/other/example.md rename to docs/other/example1.md index c1b188d..5685f0c 100644 --- a/docs/other/example.md +++ b/docs/other/example1.md @@ -1,14 +1,20 @@ ``` bash # !/bin/bash - function install_docker() { - local region_code="$(curl -s ipinfo.io/country)" - local close_firewall="true" # close firewalld service and selinux (redhat systems need) + if command -v docker &>/dev/null; then + return + fi + + # script options + local script_host="linuxmirrors.cn" # official host (CDN), more host see official site + local close_firewall="true" # close firewalld service and selinux (redhat systems need) + # mirrors options local source_docker_ce_address="mirrors.tencent.com/docker-ce" # global high availability address - local source_docker_ce_protocol="https" - local source_docker_registry_address="" + local source_docker_ce_protocol="https" # https or http + local source_docker_registry_address="registry.hub.docker.com" # judge network environment + local region_code="$(curl -s ipinfo.io/country)" if [[ "${region_code}" == "CN" ]]; then local source_intranet_address="" # use intranet source if possible @@ -36,14 +42,16 @@ function install_docker() { source_docker_ce_protocol="http" fi fi + # registry mirror (best choice for mainland China) source_docker_registry_address="docker.1ms.run" else + # use official source source_docker_ce_address="download.docker.com" source_docker_registry_address="registry.hub.docker.com" fi - # run - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ + # install docker engine + bash <(curl -sSL https://${script_host}/docker.sh) \ --source "${source_docker_ce_address}" \ --source-registry "${source_docker_registry_address}" \ --protocol "${source_docker_ce_protocol}" \ @@ -54,4 +62,4 @@ function install_docker() { } install_docker -``` +``` \ No newline at end of file diff --git a/docs/other/example2.md b/docs/other/example2.md new file mode 100644 index 0000000..65dc1d0 --- /dev/null +++ b/docs/other/example2.md @@ -0,0 +1,22 @@ +``` bash +# !/bin/bash +function install_docker() { + if command -v docker &>/dev/null; then + return + fi + + bash <(curl -sSL https://${script_host}/docker.sh) \ + --install-latest true \ + --ignore-backup-tips + + if command -v docker &>/dev/null; then + echo -e "\n# Docker installation successful.\n# Please run this script again manually after installation." + exit 0 + else + echo -e "\n# Docker installation failed.\n# Please check the error message above." + exit 1 + fi +} + +install_docker +``` \ No newline at end of file diff --git a/docs/other/index.en.md b/docs/other/index.en.md index 2f0ede7..a79d73b 100644 --- a/docs/other/index.en.md +++ b/docs/other/index.en.md @@ -4,13 +4,15 @@ hide: - footer --- +# :simple-docker:{style="color: #1d63ed"} Docker Installation & Mirror Switching Script + ???+ question "Why do you see this notice?" The script of this project currently mainly serves Simplified Chinese users, but from the very beginning it was defined as a universal mirror switching script, providing many command options for customization, which is also one of the reasons why this project is now available to users of other languages. The script output is currently fixed in Simplified Chinese. With feedback and usage from users of other languages, the script may support Traditional Chinese and English in the future. The documentation is translated with tools, and some professional terms below may be inaccurate. Corrections are welcome. -## :simple-docker:{style="color: #1d63ed"} Docker Installation & Mirror Switching Script +## One-Click Command === "Install" @@ -35,7 +37,7 @@ hide: ``` > Real-time sync, no delay. Recommended for use in mainland China network environments. - === ":gitcode: GitCode" + === ":simple-gitcode: GitCode" ``` bash bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) @@ -53,7 +55,7 @@ hide: ``` bash bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) ``` - > Not supported in mainland China network environments. + > Not recommended in mainland China network environments. Integrates installation of [`Docker Engine`](https://docs.docker.com/engine) and [`Docker Compose`](https://docs.docker.com/compose), supports selecting or switching software repositories (Docker repositories) and registry mirrors, installing specific versions, reinstalling, and supports ARM architecture. @@ -82,7 +84,7 @@ hide: ``` > Real-time sync, no delay. Recommended for use in mainland China network environments. - === ":gitcode: GitCode" + === ":simple-gitcode: GitCode" ``` bash bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) --only-registry @@ -100,7 +102,7 @@ hide: ``` bash bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) --only-registry ``` - > Not supported in mainland China network environments. + > Not recommended in mainland China network environments.
@@ -209,205 +211,213 @@ hide:
-- ### Command Options (Advanced Usage) +## Command Options (Advanced Usage) - | Name | Meaning | Value | - | :-: | :-: | :-: | - | `--source` | Specify `Docker CE` source address (domain or IP) | `address` | - | `--source-registry` | Specify `Docker` registry mirror address (domain or IP) | `address` | - | `--branch` | Specify `Docker CE` source repository (path) | `repo name (see docs below)` | - | `--branch-version` | Specify `Docker CE` source repository version | `version (see docs below)` | - | `--designated-version` | Specify `Docker Engine` installation version | `version (see docs below)` | - | `--codename` | Specify `Debian-based` OS codename | `codename` | - | `--protocol` | Specify WEB protocol for `Docker CE` source | `http` or `https` | - | `--use-intranet-source` | Prefer intranet `Docker CE` source address | `true` or `false` | - | `--install-latest` | Whether to install the latest `Docker Engine` | `true` or `false` | - | `--close-firewall` | Whether to disable the firewall | `true` or `false` | - | `--clean-screen` | Whether to clear the screen before running | `true` or `false` | - | `--only-registry` | Only switch registry mirror mode | none | - | `--ignore-backup-tips` | Ignore backup overwrite prompt (do not backup) | none | - | `--pure-mode` | Pure mode, minimal output | none | +| Name | Meaning | Value | +| :-: | :-: | :-: | +| `--source` | Specify `Docker CE` source address (domain or IP) | `address` | +| `--source-registry` | Specify `Docker` registry mirror address (domain or IP) | `address` | +| `--branch` | Specify `Docker CE` source repository (path) | `repo name (see docs below)` | +| `--branch-version` | Specify `Docker CE` source repository version | `version (see docs below)` | +| `--designated-version` | Specify `Docker Engine` installation version | `version (see docs below)` | +| `--codename` | Specify `Debian-based` OS codename | `codename` | +| `--protocol` | Specify WEB protocol for `Docker CE` source | `http` or `https` | +| `--use-intranet-source` | Prefer intranet `Docker CE` source address | `true` or `false` | +| `--install-latest` | Whether to install the latest `Docker Engine` | `true` or `false` | +| `--close-firewall` | Whether to disable the firewall | `true` or `false` | +| `--clean-screen` | Whether to clear the screen before running | `true` or `false` | +| `--only-registry` | Only switch registry mirror mode | none | +| `--ignore-backup-tips` | Ignore backup overwrite prompt (do not backup) | none | +| `--pure-mode` | Pure mode, minimal output | none | - > Full source format: `:///` +> Full source format: `:///` - - #### Specify Registry Mirror Address +- ### Specify Registry Mirror Address - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source-registry registry.example.com - ``` + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source-registry registry.example.com + ``` - - #### Only Switch Registry Mirror +- ### Only Switch Registry Mirror - === "Use Script for One-Click Replacement" + === "Use Script for One-Click Replacement" - Only switches the registry accelerator. If Docker is not installed, an error will be reported and exit. - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry - ``` - - === "Manual Replacement" - - - Install the `jq` package - - === "Debian-based / openKylin" - - ``` bash - apt-get install -y jq - ``` - - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` - - For new systems, run `apt-get update` first. - - === "RedHat-based / openEuler / OpenCloudOS / Anolis OS" - - ``` bash - dnf install -y jq || yum install -y jq - ``` - - > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - - - Specify registry mirror address - - > Manually replace `` with the registry address. See the address column in the "Built-in Registry Mirrors" table above. - - ``` bash - SOURCE_REGISTRY='"https://"' - ``` - You can also specify multiple registry mirrors, e.g., `SOURCE_REGISTRY='"https://example.registry.com","https://test.registry.com"'`, separated by commas. - - - Replace registry mirror address - - ``` bash - [ -s "/etc/docker/daemon.json" ] || echo "{}" >/etc/docker/daemon.json - jq '.["registry-mirrors"] = ['"${SOURCE_REGISTRY}"']' /etc/docker/daemon.json >/etc/docker/daemon.json.tmp && mv /etc/docker/daemon.json.tmp - ``` - - - Restart Docker service - - ``` bash - systemctl daemon-reload - [[ $(systemctl is-active docker) == "active" ]] && systemctl restart docker || systemctl enable --now docker - ``` - - - #### Specify Docker CE Source Address - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source mirror.example.com/docker-ce - ``` - > Note: The address path must include the Docker CE source repository path, i.e., `docker-ce`. - - - #### Specify Docker CE Source Repository - - The script will automatically detect this in most cases. Specify only if you have special requirements. - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --branch centos - ``` - > Repository names are fixed: `centos`, `debian`, `fedora`, `raspbian`, `rhel`, `sles`, `static`, `ubuntu` - > See [official installation docs](https://docs.docker.com/engine/install) and [Docker CE official repo](https://download.docker.com/linux) for details. - - ``` { .bash .no-copy title="Can also specify the repository version number." } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ - --branch centos \ - --branch-version 9 - ``` - > This option can be used to control the compatibility of the installed software package (only applicable to Red Hat operating systems). For details, see the path name (positive integer) representing the version number in the corresponding warehouse directory. - - - #### Specify Docker Engine Installation Version - - When specifying a version, the "install latest" option is ignored. Format: `major.minor.patch`, e.g., `28.4.1`. - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --designated-version 28.0.0 - ``` - > If the specified version does not exist or is not supported on your system, the script will report an error and exit. - - ??? quote "How to view available versions" - - === "Debian-based" - - ``` bash - apt-cache madison docker-ce | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr - ``` - - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` - - === "RedHat-based / openEuler / OpenCloudOS / Anolis OS" - - ``` bash - dnf list docker-ce --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr - ``` - - > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - - Versions not listed are not supported by this script. If you cannot get the version list, your system environment has not been properly configured for the Docker CE repository (this will not happen when running the script). - - - - #### Unattended (Automation) - - To perform installation without interaction, use at least the following options. Recommended for experienced users. - - ``` { .bash .no-copy title="Example Command" } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ - --source mirror.example.com/docker-ce \ - --source-registry registry.hub.docker.com \ - --protocol http \ - --use-intranet-source false \ - --install-latest true \ - --close-firewall true \ - --ignore-backup-tips - ``` - > If you get an "invalid option" error, check the option validity and whitespace encoding. Each option is written on a separate line for readability. - - - #### Pure Mode - - This feature is introduced to facilitate the use of developers and operation and maintenance personnel. After it is enabled, the script content output will be simplified. It is recommended to use it with other command options without interaction. + Only switches the registry accelerator. If Docker is not installed, an error will be reported and exit. ``` bash - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --pure-mode + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry ``` - !!! tip "Scrolling command logs may have unpredictable display issues, but no problems have been found so far." + === "Manual Replacement" -- ### FAQ + - Install the `jq` package - - #### About Service Startup Errors - - !!! quote "" - - In non-fresh environments, you may encounter `Docker` service startup failures after running the script. It is recommended to reinstall to resolve this. Uninstalling will not delete local images or container data. - - Uninstall commands: - - === "Debian-based" + === "Debian-based / openKylin" ``` bash - apt-get remove -y docker* containerd.io runc && apt-get autoremove + apt-get install -y jq ``` - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` + + For new systems, run `apt-get update` first. === "RedHat-based / openEuler / OpenCloudOS / Anolis OS" ``` bash - yum remove -y docker* containerd.io podman* runc + dnf install -y jq || yum install -y jq ``` > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - After uninstalling, simply rerun the script to install. + - Specify registry mirror address - - #### About unsupported operating systems + > Manually replace `` with the registry address. See the address column in the "Built-in Registry Mirrors" table above. - If it prompts that it is not supported, please use the system's own package management tool to install it. Because these packages are built and maintained by the Linux distribution's package maintainers and may have differences in configuration or are built from modified source code. + ``` bash + SOURCE_REGISTRY='"https://"' + ``` + You can also specify multiple registry mirrors, e.g., `SOURCE_REGISTRY='"https://example.registry.com","https://test.registry.com"'`, separated by commas. - You can also use [Docker Desktop](https://www.docker.com/products/docker-desktop) + - Replace registry mirror address -- ### Best Practices + ``` bash + [ -s "/etc/docker/daemon.json" ] || echo "{}" >/etc/docker/daemon.json + jq '.["registry-mirrors"] = ['"${SOURCE_REGISTRY}"']' /etc/docker/daemon.json >/etc/docker/daemon.json.tmp && mv /etc/docker/daemon.json.tmp + ``` -
- Code examples for enterprise product deployment and automated operations such as CI/CD (expand to view) - --8<-- "docs/other/example.md" -
+ - Restart Docker service + + ``` bash + systemctl daemon-reload + [[ $(systemctl is-active docker) == "active" ]] && systemctl restart docker || systemctl enable --now docker + ``` + +- ### Specify Docker CE Source Address + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source mirror.example.com/docker-ce + ``` + > Note: The address path must include the Docker CE source repository path, i.e., `docker-ce`. + +- ### Specify Docker CE Source Repository + + The script will automatically detect this in most cases. Specify only if you have special requirements. + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --branch centos + ``` + > Repository names are fixed: `centos`, `debian`, `fedora`, `raspbian`, `rhel`, `sles`, `static`, `ubuntu` + > See [official installation docs](https://docs.docker.com/engine/install) and [Docker CE official repo](https://download.docker.com/linux) for details. + + ``` { .bash .no-copy title="Can also specify the repository version number." } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ + --branch centos \ + --branch-version 9 + ``` + > This option can be used to control the compatibility of the installed software package (only applicable to Red Hat operating systems). For details, see the path name (positive integer) representing the version number in the corresponding warehouse directory. + +- ### Specify Docker Engine Installation Version + + When specifying a version, the "install latest" option is ignored. Format: `major.minor.patch`, e.g., `28.4.1`. + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --designated-version 28.0.0 + ``` + > If the specified version does not exist or is not supported on your system, the script will report an error and exit. + + ??? quote "How to view available versions" + + === "Debian-based" + + ``` bash + apt-cache madison docker-ce | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + + === "RedHat-based / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + dnf list docker-ce --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + Versions not listed are not supported by this script. If you cannot get the version list, your system environment has not been properly configured for the Docker CE repository (this will not happen when running the script). + + +- ### Unattended (Automation) + + To perform installation without interaction, use at least the following options. Recommended for experienced users. + + ``` { .bash .no-copy title="Example Command" } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ + --source mirror.example.com/docker-ce \ + --source-registry registry.hub.docker.com \ + --protocol http \ + --use-intranet-source false \ + --install-latest true \ + --close-firewall true \ + --ignore-backup-tips + ``` + > If you get an "invalid option" error, check the option validity and whitespace encoding. Each option is written on a separate line for readability. + +- ### Pure Mode + + This feature is introduced to facilitate the use of developers and operation and maintenance personnel. After it is enabled, the script content output will be simplified. It is recommended to use it with other command options without interaction. + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --pure-mode + ``` + + !!! tip "Scrolling command logs may have unpredictable display issues, but no problems have been found so far." + +## FAQ + +- ### About Service Startup Errors + + !!! quote "" + + In non-fresh environments, you may encounter `Docker` service startup failures after running the script. It is recommended to reinstall to resolve this. Uninstalling will not delete local images or container data. + + Uninstall commands: + + === "Debian-based" + + ``` bash + apt-get remove -y docker* containerd.io runc && apt-get autoremove + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + + === "RedHat-based / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + yum remove -y docker* containerd.io podman* runc + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + After uninstalling, simply rerun the script to install. + +- ### About unsupported operating systems + + If it prompts that it is not supported, please use the system's own package management tool to install it. Because these packages are built and maintained by the Linux distribution's package maintainers and may have differences in configuration or are built from modified source code. + + You can also use   [![Docker Desktop](/assets/images/icon/custom/docker-desktop.svg){ width="140" style="vertical-align: -0.2rem" }](https://www.docker.com/products/docker-desktop) + +## Best Practices + +??? note "Code examples for enterprise product deployment and automated operations such as CI/CD (expand to view)" + + If you don't want any user interaction, use the `fully automated` example. + + - #### Fully automated (recommended) + + --8<-- "docs/other/example1.md" + + - #### Simple method + + --8<-- "docs/other/example2.md" + > Note: If you don't specify `Docker CE source` and `Image repository source`, the script will be interactively selected by the user. The screen will be automatically cleared (`$ clear`) at this point, which will cause your script's log to be cleared. diff --git a/docs/other/index.md b/docs/other/index.md index f52b491..baa21cf 100644 --- a/docs/other/index.md +++ b/docs/other/index.md @@ -4,7 +4,9 @@ hide: - footer --- -## :simple-docker:{style="color: #1d63ed"} Docker 安装与换源脚本 +# :simple-docker:{style="color: #1d63ed"} Docker 安装与换源脚本 + +## 一键执行命令 === "安装" @@ -29,7 +31,7 @@ hide: ``` > 实时同步、无延迟,国内网络环境下推荐使用 - === ":gitcode: GitCode (镜像仓库)" + === ":simple-gitcode: GitCode (镜像仓库)" ``` bash bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) @@ -47,7 +49,7 @@ hide: ``` bash bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) ``` - > 不支持在国内网络环境下使用 + > 不建议在国内网络环境下使用 集成安装 [`Docker Engine`](https://docs.docker.com/engine) 和 [`Docker Compose`](https://docs.docker.com/compose),支持选择或更换软件源(Docker 软件仓库)以及镜像仓库、安装指定版本、重装等功能,支持 ARM 架构 @@ -76,7 +78,7 @@ hide: ``` > 实时同步、无延迟,国内网络环境下推荐使用 - === ":gitcode: GitCode (镜像仓库)" + === ":simple-gitcode: GitCode (镜像仓库)" ``` bash bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) --only-registry @@ -94,7 +96,7 @@ hide: ``` bash bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) --only-registry ``` - > 不支持在国内网络环境下使用 + > 不建议在国内网络环境下使用
@@ -203,227 +205,235 @@ hide:
-- ### 命令选项(高级用法) +## 命令选项(高级用法) - - ``` - $ bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --help + +``` +$ bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --help - 命令选项(名称/含义/值): +命令选项(名称/含义/值): - --source 指定 Docker CE 软件源地址(域名或IP) 地址 - --source-registry 指定 Docker 镜像仓库地址(域名或IP) 地址 - --branch 指定 Docker CE 软件源仓库(路径) 仓库名 - --branch-version 指定 Docker CE 软件源仓库版本 版本号 - --designated-version 指定 Docker Engine 安装版本 版本号 - --codename 指定 Debian 系操作系统的版本代号 代号名称 - --protocol 指定 Docker CE 软件源的 WEB 协议 http 或 https - --use-intranet-source 是否优先使用内网 Docker CE 软件源地址 true 或 false - --install-latest 是否安装最新版本的 Docker Engine true 或 false - --close-firewall 是否关闭防火墙 true 或 false - --clean-screen 是否在运行前清除屏幕上的所有内容 true 或 false - --only-registry 仅更换镜像仓库模式 无 - --ignore-backup-tips 忽略覆盖备份提示 无 - --pure-mode 纯净模式,精简打印内容 无 + --source 指定 Docker CE 软件源地址(域名或IP) 地址 + --source-registry 指定 Docker 镜像仓库地址(域名或IP) 地址 + --branch 指定 Docker CE 软件源仓库(路径) 仓库名 + --branch-version 指定 Docker CE 软件源仓库版本 版本号 + --designated-version 指定 Docker Engine 安装版本 版本号 + --codename 指定 Debian 系操作系统的版本代号 代号名称 + --protocol 指定 Docker CE 软件源的 WEB 协议 http 或 https + --use-intranet-source 是否优先使用内网 Docker CE 软件源地址 true 或 false + --install-latest 是否安装最新版本的 Docker Engine true 或 false + --close-firewall 是否关闭防火墙 true 或 false + --clean-screen 是否在运行前清除屏幕上的所有内容 true 或 false + --only-registry 仅更换镜像仓库模式 无 + --ignore-backup-tips 忽略覆盖备份提示 无 + --pure-mode 纯净模式,精简打印内容 无 +``` + +| 名称 | 含义 | 选项值 | +| :-: | :-: | :-: | +| `--source` | 指定 `Docker CE` 源地址(域名或IP) | `地址` | +| `--source-registry` | 指定 `Docker` 镜像仓库地址(域名或IP) | `地址` | +| `--branch` | 指定 `Docker CE` 软件源仓库(路径) | `仓库名(详见下方文档)` | +| `--branch-version` | 指定 `Docker CE` 软件源仓库版本 | `版本号(详见下方文档)` | +| `--designated-version` | 指定 `Docker Engine` 安装版本 | `版本号(详见下方文档)` | +| `--codename` | 指定 `Debian` 系操作系统的版本代号 | `代号名称` | +| `--protocol` | 指定 `Docker CE` 源的 WEB 协议 | `http` 或 `https` | +| `--use-intranet-source` | 是否优先使用内网 `Docker CE` 软件源地址 | `true` 或 `false` | +| `--install-latest` | 是否安装最新版本的 `Docker Engine` | `true` 或 `false` | +| `--close-firewall` | 是否关闭防火墙 | `true` 或 `false` | +| `--clean-screen` | 是否在运行前清除屏幕上的所有内容 | `true` 或 `false` | +| `--only-registry` | 仅更换镜像仓库模式 | 无 | +| `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 | +| `--pure-mode` | 纯净模式,精简打印内容 | 无 | + +> 软件源完整格式 `://<软件源地址(域名或IP)>/<软件源仓库(路径)>` + +- ### 指定镜像仓库地址 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source-registry registry.example.com ``` - | 名称 | 含义 | 选项值 | - | :-: | :-: | :-: | - | `--source` | 指定 `Docker CE` 源地址(域名或IP) | `地址` | - | `--source-registry` | 指定 `Docker` 镜像仓库地址(域名或IP) | `地址` | - | `--branch` | 指定 `Docker CE` 软件源仓库(路径) | `仓库名(详见下方文档)` | - | `--branch-version` | 指定 `Docker CE` 软件源仓库版本 | `版本号(详见下方文档)` | - | `--designated-version` | 指定 `Docker Engine` 安装版本 | `版本号(详见下方文档)` | - | `--codename` | 指定 `Debian` 系操作系统的版本代号 | `代号名称` | - | `--protocol` | 指定 `Docker CE` 源的 WEB 协议 | `http` 或 `https` | - | `--use-intranet-source` | 是否优先使用内网 `Docker CE` 软件源地址 | `true` 或 `false` | - | `--install-latest` | 是否安装最新版本的 `Docker Engine` | `true` 或 `false` | - | `--close-firewall` | 是否关闭防火墙 | `true` 或 `false` | - | `--clean-screen` | 是否在运行前清除屏幕上的所有内容 | `true` 或 `false` | - | `--only-registry` | 仅更换镜像仓库模式 | 无 | - | `--ignore-backup-tips` | 忽略覆盖备份提示(即不覆盖备份) | 无 | - | `--pure-mode` | 纯净模式,精简打印内容 | 无 | +- ### 仅更换镜像仓库 - > 软件源完整格式 `://<软件源地址(域名或IP)>/<软件源仓库(路径)>` + === "使用脚本一键替换" - - #### 指定镜像仓库地址 - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source-registry registry.example.com - ``` - - - #### 仅更换镜像仓库 - - === "使用脚本一键替换" - - 仅更换镜像加速器,当检测到未安装 Docker 时会报错跳出 - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry - ``` - - === "手动替换" - - - 安装 `jq` 软件包 - - === "Debian 系 / openKylin" - - ``` bash - apt-get install -y jq - ``` - - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` - - 新装系统需要先执行一遍更新 `apt-get update` - - === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" - - ``` bash - dnf install -y jq || yum install -y jq - ``` - - > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - - - 指定镜像仓库地址 - - > 请手动替换 `` 为镜像仓库地址后在执行,详见上方 “项目内置的镜像仓库源” 表格中的地址列 - - ``` bash - SOURCE_REGISTRY='"https://"' - ``` - 还可以指定多个镜像仓库,如 `SOURCE_REGISTRY='"https://example.registry.com","https://test.registry.com"'`,注意用英文逗号分割 - - - 替换镜像仓库地址 - - ``` bash - [ -s "/etc/docker/daemon.json" ] || echo "{}" >/etc/docker/daemon.json - jq '.["registry-mirrors"] = ['"${SOURCE_REGISTRY}"']' /etc/docker/daemon.json >/etc/docker/daemon.json.tmp && mv /etc/docker/daemon.json.tmp - ``` - - - 重启 Docker 服务 - - ``` bash - systemctl daemon-reload - [[ $(systemctl is-active docker) == "active" ]] && systemctl restart docker || systemctl enable --now docker - ``` - - - #### 指定 Docker CE 软件源地址 - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source mirror.example.com/docker-ce - ``` - > 注意该地址路径需要包含镜像站的 Docker CE 软件源仓库路径即 `docker-ce` - - - #### 指定 Docker CE 软件源仓库 - - 脚本默认会自动判断一般无需指定,除非你有特殊需求 - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --branch centos - ``` - > 仓库名是固定的,目前只有 `centos` `debian` `fedora` `raspbian` `rhel` `sles` `static` `ubuntu` 这几个 - > 具体详见 [官方安装文档](https://docs.docker.com/engine/install) 和 [Docker CE 官方仓库](https://download.docker.com/linux) - - ``` { .bash .no-copy title="还可以指定仓库版本号" } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ - --branch centos \ - --branch-version 9 - ``` - > 可以使用该选项来控制安装软件包的兼容性(仅适用于红帽系操作系统),具体详见对应仓库目录中代表版本号的路径名称(正整数)。 - - - #### 指定 Docker Engine 安装版本 - - 指定安装版本时会忽略 `是否安装最新版本` 的命令选项,格式为 `主版本.次版本.补丁版本`,例如 `28.4.1`。 - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --designated-version 28.0.0 - ``` - > 如果指定的版本不存在或者不支持当前系统,届时脚本会报错跳出 - - ??? quote "查看版本列表的方法" - - === "Debian 系" - - ``` bash - apt-cache madison docker-ce | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr - ``` - - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` - - === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" - - ``` bash - dnf list docker-ce --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr - ``` - - > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - - 未出现在该列表中的版本则不支持通过本脚本安装,如果获取不到版本列表说明你当前的系统环境还没有正确配置 Docker CE 软件源(运行脚本时不存在该问题) - - - - #### 无人值守(自动化) - - 不通过交互完成安装操作,至少需要使用如下命令选项来实现,建议熟悉后再使用 - - ``` { .bash .no-copy title="参考命令" } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ - --source mirror.example.com/docker-ce \ - --source-registry registry.hub.docker.com \ - --protocol http \ - --use-intranet-source false \ - --install-latest true \ - --close-firewall true \ - --ignore-backup-tips - ``` - > 如果报错 `命令选项无效` 那么请检查选项合法性以及空格字符编码,在示例中一行写一个选项是为了提高命令的可读性 - - - #### 纯净模式 - - 推出该功能是为了便于开发以及运维人员使用,启用后会精简脚本内容输出,建议搭配其它命令选项无交互使用 + 仅更换镜像加速器,当检测到未安装 Docker 时会报错跳出 ``` bash - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --pure-mode + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry ``` - !!! tip "滚动输出的命令日志可能存在无法预料的显示问题,不过目前暂未发现异常" + === "手动替换" -- ### 常见问题 + - 安装 `jq` 软件包 - - #### 关于服务报错无法启动 - - !!! quote "" - - 非新装环境可能会在运行脚本后遇到 `Docker` 服务无法启动的情况,建议重新安装来解决,卸载不会删除本地镜像和容器数据 - - 卸载命令如下: - - === "Debian 系" + === "Debian 系 / openKylin" ``` bash - apt-get remove -y docker* containerd.io runc && apt-get autoremove + apt-get install -y jq ``` - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` + + 新装系统需要先执行一遍更新 `apt-get update` === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" ``` bash - yum remove -y docker* containerd.io podman* runc + dnf install -y jq || yum install -y jq ``` > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - 卸载完成后重新执行脚本安装即可 + - 指定镜像仓库地址 - - #### 关于不支持的操作系统 + > 请手动替换 `` 为镜像仓库地址后在执行,详见上方 “项目内置的镜像仓库源” 表格中的地址列 - 如果提示不支持那么请使用系统自带的包管理工具进行安装。因为这些软件包由 Linux 发行版的软件包维护者构建和维护,可能存在配置差异或由修改后的源代码构建。 + ``` bash + SOURCE_REGISTRY='"https://"' + ``` + 还可以指定多个镜像仓库,如 `SOURCE_REGISTRY='"https://example.registry.com","https://test.registry.com"'`,注意用英文逗号分割 - 也可以使用 [Docker Desktop](https://www.docker.com/products/docker-desktop) + - 替换镜像仓库地址 -- ### 最佳实践 + ``` bash + [ -s "/etc/docker/daemon.json" ] || echo "{}" >/etc/docker/daemon.json + jq '.["registry-mirrors"] = ['"${SOURCE_REGISTRY}"']' /etc/docker/daemon.json >/etc/docker/daemon.json.tmp && mv /etc/docker/daemon.json.tmp + ``` -
- 适用于企业产品部署以及 CI/CD 等自动化运维场景的代码示例(展开查看) - --8<-- "docs/other/example.md" -
+ - 重启 Docker 服务 + + ``` bash + systemctl daemon-reload + [[ $(systemctl is-active docker) == "active" ]] && systemctl restart docker || systemctl enable --now docker + ``` + +- ### 指定 Docker CE 软件源地址 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source mirror.example.com/docker-ce + ``` + > 注意该地址路径需要包含镜像站的 Docker CE 软件源仓库路径即 `docker-ce` + +- ### 指定 Docker CE 软件源仓库 + + 脚本默认会自动判断一般无需指定,除非你有特殊需求 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --branch centos + ``` + > 仓库名是固定的,目前只有 `centos` `debian` `fedora` `raspbian` `rhel` `sles` `static` `ubuntu` 这几个 + > 具体详见 [官方安装文档](https://docs.docker.com/engine/install) 和 [Docker CE 官方仓库](https://download.docker.com/linux) + + ``` { .bash .no-copy title="还可以指定仓库版本号" } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ + --branch centos \ + --branch-version 9 + ``` + > 可以使用该选项来控制安装软件包的兼容性(仅适用于红帽系操作系统),具体详见对应仓库目录中代表版本号的路径名称(正整数)。 + +- ### 指定 Docker Engine 安装版本 + + 指定安装版本时会忽略 `是否安装最新版本` 的命令选项,格式为 `主版本.次版本.补丁版本`,例如 `28.4.1`。 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --designated-version 28.0.0 + ``` + > 如果指定的版本不存在或者不支持当前系统,届时脚本会报错跳出 + + ??? quote "查看版本列表的方法" + + === "Debian 系" + + ``` bash + apt-cache madison docker-ce | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + + === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + dnf list docker-ce --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + 未出现在该列表中的版本则不支持通过本脚本安装,如果获取不到版本列表说明你当前的系统环境还没有正确配置 Docker CE 软件源(运行脚本时不存在该问题) + + +- ### 无人值守(自动化) + + 不通过交互完成安装操作,至少需要使用如下命令选项来实现,建议熟悉后再使用 + + ``` { .bash .no-copy title="参考命令" } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ + --source mirror.example.com/docker-ce \ + --source-registry registry.hub.docker.com \ + --protocol http \ + --use-intranet-source false \ + --install-latest true \ + --close-firewall true \ + --ignore-backup-tips + ``` + > 如果报错 `命令选项无效` 那么请检查选项合法性以及空格字符编码,在示例中一行写一个选项是为了提高命令的可读性 + +- ### 纯净模式 + + 推出该功能是为了便于开发以及运维人员使用,启用后会精简脚本内容输出,建议搭配其它命令选项无交互使用 + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --pure-mode + ``` + + !!! tip "滚动输出的命令日志可能存在无法预料的显示问题,不过目前暂未发现异常" + +## 常见问题 + +- ### 关于服务报错无法启动 + + !!! quote "" + + 非新装环境可能会在运行脚本后遇到 `Docker` 服务无法启动的情况,建议重新安装来解决,卸载不会删除本地镜像和容器数据 + + 卸载命令如下: + + === "Debian 系" + + ``` bash + apt-get remove -y docker* containerd.io runc && apt-get autoremove + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + + === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + yum remove -y docker* containerd.io podman* runc + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + 卸载完成后重新执行脚本安装即可 + +- ### 关于不支持的操作系统 + + 如果提示不支持那么请使用系统自带的包管理工具进行安装。因为这些软件包由 Linux 发行版的软件包维护者构建和维护,可能存在配置差异或由修改后的源代码构建。 + + 也可以使用   [![Docker Desktop](/assets/images/icon/custom/docker-desktop.svg){ width="140" style="vertical-align: -0.2rem" }](https://www.docker.com/products/docker-desktop) + +## 最佳实践 + +??? note "适用于企业产品部署以及 CI/CD 等自动化运维场景的代码示例(展开查看)" + + 如果你不想让用户进行任何交互,请使用 `完全自动化` 示例 + + - #### 完全自动化(推荐) + + --8<-- "docs/other/example1.md" + + - #### 简易方式 + + --8<-- "docs/other/example2.md" + > 注:不指定 `Docker CE 源` 以及 `镜像仓库源` 则会交由用户进行交互选择,届时会自动清屏 `$ clear`,从而导致你脚本的运行日志被清除 diff --git a/docs/other/index.zh-Hant.md b/docs/other/index.zh-Hant.md index 48eb12d..0cd77ee 100644 --- a/docs/other/index.zh-Hant.md +++ b/docs/other/index.zh-Hant.md @@ -4,13 +4,15 @@ hide: - footer --- +# :simple-docker:{style="color: #1d63ed"} Docker 安裝與換源腳本 + ???+ question "為什麼會看到該提示?" 本項目腳本目前主要服務於簡體中文用戶,但是從立項之初就定義為了通用換源腳本,提供了諸多命令選項用於自定義使用,這也是本項目為什麼開始面向其它語言用戶使用的原因之一。腳本列印內容目前固定為簡體中文,隨著其它語言使用者的回饋和使用,腳本將來可能會支援繁體中文和英文。 文檔使用工具進行翻譯,下方內容中的專業術語可能存在不準確的情況,歡迎修正。 -## :simple-docker:{style="color: #1d63ed"} Docker 安裝與換源腳本 +## 一鍵執行命令 === "安裝" @@ -35,7 +37,7 @@ hide: ``` > 即時同步、無延遲,中國大陸網路環境建議使用 - === ":gitcode: GitCode (鏡像倉庫)" + === ":simple-gitcode: GitCode (鏡像倉庫)" ``` bash bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) @@ -53,7 +55,7 @@ hide: ``` bash bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) ``` - > 不支援在中國大陸網路環境下使用 + > 不建議在中國大陸網路環境下使用 整合安裝 [`Docker Engine`](https://docs.docker.com/engine) 和 [`Docker Compose`](https://docs.docker.com/compose),支援選擇或更換軟體源(Docker 軟體倉庫)以及鏡像倉庫、安裝指定版本、重裝等功能,支援 ARM 架構 @@ -82,7 +84,7 @@ hide: ``` > 即時同步、無延遲,中國大陸網路環境建議使用 - === ":gitcode: GitCode (鏡像倉庫)" + === ":simple-gitcode: GitCode (鏡像倉庫)" ``` bash bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) --only-registry @@ -100,7 +102,7 @@ hide: ``` bash bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) --only-registry ``` - > 不支援在中國大陸網路環境下使用 + > 不建議在中國大陸網路環境下使用
@@ -209,205 +211,213 @@ hide:
-- ### 命令選項(進階用法) +## 命令選項(進階用法) - | 名稱 | 意義 | 選項值 | - | :-: | :-: | :-: | - | `--source` | 指定 `Docker CE` 軟體源位址(網域名稱或IP) | `位址` | - | `--source-registry` | 指定 `Docker` 鏡像倉庫位址(網域名稱或IP) | `位址` | - | `--branch` | 指定 `Docker CE` 軟體源倉庫(路徑) | `倉庫名稱(詳見下方文檔)` | - | `--branch-version` | 指定 `Docker CE` 軟體源倉庫版本 | `版本號(詳見下方文檔)` | - | `--designated-version` | 指定 `Docker Engine` 安裝版本 | `版本號(詳見下方文檔)` | - | `--codename` | 指定 `Debian` 係作業系統的版本代號 | `代號名稱` | - | `--protocol` | 指定 `Docker CE` 源的 WEB 協議 | `http` 或 `https` | - | `--use-intranet-source` | 是否優先使用內部網路 `Docker CE` 軟體源位址 | `true` 或 `false` | - | `--install-latest` | 是否安裝最新版本的 `Docker Engine` | `true` 或 `false` | - | `--close-firewall` | 是否關閉防火牆 | `true` 或 `false` | - | `--clean-screen` | 是否在運行前清除螢幕上的所有內容 | `true` 或 `false` | - | `--only-registry` | 僅更換鏡像倉庫模式 | 無 | - | `--ignore-backup-tips` | 忽略覆蓋備份提示(即不覆蓋備份) | - | `--pure-mode` | 純淨模式,精簡列印內容 | 無 | +| 名稱 | 意義 | 選項值 | +| :-: | :-: | :-: | +| `--source` | 指定 `Docker CE` 軟體源位址(網域名稱或IP) | `位址` | +| `--source-registry` | 指定 `Docker` 鏡像倉庫位址(網域名稱或IP) | `位址` | +| `--branch` | 指定 `Docker CE` 軟體源倉庫(路徑) | `倉庫名稱(詳見下方文檔)` | +| `--branch-version` | 指定 `Docker CE` 軟體源倉庫版本 | `版本號(詳見下方文檔)` | +| `--designated-version` | 指定 `Docker Engine` 安裝版本 | `版本號(詳見下方文檔)` | +| `--codename` | 指定 `Debian` 係作業系統的版本代號 | `代號名稱` | +| `--protocol` | 指定 `Docker CE` 源的 WEB 協議 | `http` 或 `https` | +| `--use-intranet-source` | 是否優先使用內部網路 `Docker CE` 軟體源位址 | `true` 或 `false` | +| `--install-latest` | 是否安裝最新版本的 `Docker Engine` | `true` 或 `false` | +| `--close-firewall` | 是否關閉防火牆 | `true` 或 `false` | +| `--clean-screen` | 是否在運行前清除螢幕上的所有內容 | `true` 或 `false` | +| `--only-registry` | 僅更換鏡像倉庫模式 | 無 | +| `--ignore-backup-tips` | 忽略覆蓋備份提示(即不覆蓋備份) | +| `--pure-mode` | 純淨模式,精簡列印內容 | 無 | - > 軟體源完整格式 `://<軟體源位址(網域名稱或IP)>/<軟體源倉庫(路徑)>` +> 軟體源完整格式 `://<軟體源位址(網域名稱或IP)>/<軟體源倉庫(路徑)>` - - #### 指定鏡像倉庫位址 +- ### 指定鏡像倉庫位址 - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source-registry registry.example.com - ``` + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source-registry registry.example.com + ``` - - #### 僅更換鏡像倉庫 +- ### 僅更換鏡像倉庫 - === "使用腳本一鍵替換" + === "使用腳本一鍵替換" - 僅更換鏡像加速器,當偵測到未安裝 Docker 時會報錯跳出 - - ``` bash - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry - ``` - - === "手動替換" - - - 安裝 `jq` 軟體包 - - === "Debian 係 / openKylin" - - ``` bash - apt-get install -y jq - ``` - - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` - - 新裝系統需要先執行一次更新 `apt-get update` - - === "RedHat 係 / openEuler / OpenCloudOS / Anolis OS" - - ``` bash - dnf install -y jq || yum install -y jq - ``` - - > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - - - 指定鏡像倉庫位址 - - > 請手動替換 `` 為鏡像倉庫位址後在執行,詳見上方 “項目內置的鏡像倉庫源” 表格中的位址列 - - ``` bash - SOURCE_REGISTRY='"https://"' - ``` - 也可以指定多個鏡像倉庫,如 `SOURCE_REGISTRY='"https://example.registry.com","https://test.registry.com"'`,注意用英文逗號分割 - - - 替換鏡像倉庫位址 - - ``` bash - [ -s "/etc/docker/daemon.json" ] || echo "{}" >/etc/docker/daemon.json - jq '.["registry-mirrors"] = ['"${SOURCE_REGISTRY}"']' /etc/docker/daemon.json >/etc/docker/daemon.json.tmp && mv /etc/docker/daemon.json.tmp - ``` - - - 重新啟動 Docker 服務 - - ``` bash - systemctl daemon-reload - [[ $(systemctl is-active docker) == "active" ]] && systemctl restart docker || systemctl enable --now docker - ``` - - - #### 指定 `Docker CE` 軟體源位址 - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source mirror.example.com/docker-ce - ``` - > 注意該位址路徑需要包含映像站的 Docker CE 軟體源倉庫路徑即 `docker-ce` - - - #### 指定 Docker CE 軟體源倉庫 - - 腳本預設會自動判斷一般無需指定,除非你有特殊需求 - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --branch centos - ``` - > 倉庫名稱是固定的,目前只有 `centos` `debian` `fedora` `raspbian` `rhel` `sles` `static` `ubuntu` 這幾個 - > 詳情請見 [官方安裝文檔](https://docs.docker.com/engine/install) 及 [Docker CE 官方倉庫](https://download.docker.com/linux) - - ``` { .bash .no-copy title="还可以指定倉庫版本號" } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ - --branch centos \ - --branch-version 9 - ``` - > 可以使用此選項來控制安裝軟體套件的相容性(僅適用於紅帽係作業系統),具體詳見對應倉庫目錄中代表版本號的路徑名稱(正整數)。 - - - #### 指定 Docker Engine 安裝版本 - - 指定安裝版本時會忽略 `是否安裝最新版本` 的命令選項,格式為 `主版.次版本.補丁版本`,例如 `28.4.1`。 - - ``` { .bash .no-copy } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --designated-version 28.0.0 - ``` - > 如果指定的版本不存在或不支援目前系統,屆時腳本會報錯跳出 - - ??? quote "查看版本清單的方法" - - === "Debian 系" - - ``` bash - apt-cache madison docker-ce | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr - ``` - - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` - - === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" - - ``` bash - dnf list docker-ce --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr - ``` - - > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - - 未出現在該清單中的版本則不支援透過本腳本安裝,如果取得不到版本清單說明你目前的系統環境還沒有正確配置 Docker CE 軟體軟體源(執行腳本時不存在該問題) - - - - #### 無人值守(自動化) - - 不透過交互完成安裝操作,至少需要使用以下命令選項來實現,建議熟悉後再使用 - - ``` { .bash .no-copy title="参考命令" } - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ - --source mirror.example.com/docker-ce \ - --source-registry registry.hub.docker.com \ - --protocol http \ - --use-intranet-source false \ - --install-latest true \ - --close-firewall true \ - --ignore-backup-tips - ``` - > 如果報錯 `命令選項無效` 那麼請檢查選項合法性以及空格字元編碼,在範例中一行寫一個選項是為了提高命令的可讀性 - - - #### 純淨模式 - - 推出此功能是為了方便開發以及运维人員使用,啟用後會精簡腳本內容輸出,建議搭配其它指令選項無互動使用 + 僅更換鏡像加速器,當偵測到未安裝 Docker 時會報錯跳出 ``` bash - bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --pure-mode + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --only-registry ``` - !!! tip "滾動輸出的命令日誌可能有無法預料的顯示問題,不過目前暫未發現異常" + === "手動替換" -- ### 常見問題 + - 安裝 `jq` 軟體包 - - #### 關於服務報錯無法啟動 - - !!! quote "" - - 非新裝環境可能會在執行腳本後遇到 `Docker` 服務無法啟動的情況,建議重新安裝來解決,卸載不會刪除本機映像和容器資料 - - 卸載指令如下: - - === "Debian 系" + === "Debian 係 / openKylin" ``` bash - apt-get remove -y docker* containerd.io runc && apt-get autoremove + apt-get install -y jq ``` - > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS`   `openKylin` - === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + 新裝系統需要先執行一次更新 `apt-get update` + + === "RedHat 係 / openEuler / OpenCloudOS / Anolis OS" ``` bash - yum remove -y docker* containerd.io podman* runc + dnf install -y jq || yum install -y jq ``` > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` - 卸載完成後重新執行腳本安裝即可 + - 指定鏡像倉庫位址 - - #### 關於不支援的作業系統 + > 請手動替換 `` 為鏡像倉庫位址後在執行,詳見上方 “項目內置的鏡像倉庫源” 表格中的位址列 - 如果提示不支援那麼請使用系統自備的套件管理工具進行安裝。因為這些軟體包由 Linux 發行版的軟體包維護者建構和維護,可能存在配置差異或由修改後的原始碼建構。 + ``` bash + SOURCE_REGISTRY='"https://"' + ``` + 也可以指定多個鏡像倉庫,如 `SOURCE_REGISTRY='"https://example.registry.com","https://test.registry.com"'`,注意用英文逗號分割 - 也可以使用 [Docker Desktop](https://www.docker.com/products/docker-desktop) + - 替換鏡像倉庫位址 -- ### 最佳實踐 + ``` bash + [ -s "/etc/docker/daemon.json" ] || echo "{}" >/etc/docker/daemon.json + jq '.["registry-mirrors"] = ['"${SOURCE_REGISTRY}"']' /etc/docker/daemon.json >/etc/docker/daemon.json.tmp && mv /etc/docker/daemon.json.tmp + ``` -
- 適用於企業產品部署以及 CI/CD 等自動化維運場景的程式碼範例(展開檢視) - --8<-- "docs/other/example.md" -
+ - 重新啟動 Docker 服務 + + ``` bash + systemctl daemon-reload + [[ $(systemctl is-active docker) == "active" ]] && systemctl restart docker || systemctl enable --now docker + ``` + +- ### 指定 `Docker CE` 軟體源位址 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --source mirror.example.com/docker-ce + ``` + > 注意該位址路徑需要包含映像站的 Docker CE 軟體源倉庫路徑即 `docker-ce` + +- ### 指定 Docker CE 軟體源倉庫 + + 腳本預設會自動判斷一般無需指定,除非你有特殊需求 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --branch centos + ``` + > 倉庫名稱是固定的,目前只有 `centos` `debian` `fedora` `raspbian` `rhel` `sles` `static` `ubuntu` 這幾個 + > 詳情請見 [官方安裝文檔](https://docs.docker.com/engine/install) 及 [Docker CE 官方倉庫](https://download.docker.com/linux) + + ``` { .bash .no-copy title="还可以指定倉庫版本號" } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ + --branch centos \ + --branch-version 9 + ``` + > 可以使用此選項來控制安裝軟體套件的相容性(僅適用於紅帽係作業系統),具體詳見對應倉庫目錄中代表版本號的路徑名稱(正整數)。 + +- ### 指定 Docker Engine 安裝版本 + + 指定安裝版本時會忽略 `是否安裝最新版本` 的命令選項,格式為 `主版.次版本.補丁版本`,例如 `28.4.1`。 + + ``` { .bash .no-copy } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --designated-version 28.0.0 + ``` + > 如果指定的版本不存在或不支援目前系統,屆時腳本會報錯跳出 + + ??? quote "查看版本清單的方法" + + === "Debian 系" + + ``` bash + apt-cache madison docker-ce | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + + === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + dnf list docker-ce --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9]{1,2}.[0-9]{1,2}" | sort -t '.' -k1,1nr -k2,2nr -k3,3nr + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + 未出現在該清單中的版本則不支援透過本腳本安裝,如果取得不到版本清單說明你目前的系統環境還沒有正確配置 Docker CE 軟體軟體源(執行腳本時不存在該問題) + + +- ### 無人值守(自動化) + + 不透過交互完成安裝操作,至少需要使用以下命令選項來實現,建議熟悉後再使用 + + ``` { .bash .no-copy title="参考命令" } + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) \ + --source mirror.example.com/docker-ce \ + --source-registry registry.hub.docker.com \ + --protocol http \ + --use-intranet-source false \ + --install-latest true \ + --close-firewall true \ + --ignore-backup-tips + ``` + > 如果報錯 `命令選項無效` 那麼請檢查選項合法性以及空格字元編碼,在範例中一行寫一個選項是為了提高命令的可讀性 + +- ### 純淨模式 + + 推出此功能是為了方便開發以及运维人員使用,啟用後會精簡腳本內容輸出,建議搭配其它指令選項無互動使用 + + ``` bash + bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --pure-mode + ``` + + !!! tip "滾動輸出的命令日誌可能有無法預料的顯示問題,不過目前暫未發現異常" + +## 常見問題 + +- ### 關於服務報錯無法啟動 + + !!! quote "" + + 非新裝環境可能會在執行腳本後遇到 `Docker` 服務無法啟動的情況,建議重新安裝來解決,卸載不會刪除本機映像和容器資料 + + 卸載指令如下: + + === "Debian 系" + + ``` bash + apt-get remove -y docker* containerd.io runc && apt-get autoremove + ``` + + > `Debian`   `Ubuntu`   `Kali`   `Linux Mint`   `Deepin`   `Zorin OS`   `Armbian`   `Proxmox VE`   `Raspberry Pi OS` + + === "RedHat 系 / openEuler / OpenCloudOS / Anolis OS" + + ``` bash + yum remove -y docker* containerd.io podman* runc + ``` + + > `Red Hat Enterprise Linux`   `CentOS`   `Rocky Linux`   `AlmaLinux`   `Fedora`   `openEuler`   `OpenCloudOS`   `Anolis OS` + + 卸載完成後重新執行腳本安裝即可 + +- ### 關於不支援的作業系統 + + 如果提示不支援那麼請使用系統自備的套件管理工具進行安裝。因為這些軟體包由 Linux 發行版的軟體包維護者建構和維護,可能存在配置差異或由修改後的原始碼建構。 + + 也可以使用   [![Docker Desktop](/assets/images/icon/custom/docker-desktop.svg){ width="140" style="vertical-align: -0.2rem" }](https://www.docker.com/products/docker-desktop) + +- ## 最佳實踐 + +??? note "適用於企業產品部署以及 CI/CD 等自動化維運場景的程式碼範例(展開檢視)" + + 如果你不想讓用戶進行任何交互,請使用 `完全自動化` 範例 + + - #### 完全自動化(建議) + + --8<-- "docs/other/example1.md" + + - #### 簡易方式 + + --8<-- "docs/other/example2.md" + > 註:不指定 `Docker CE 源` 以及 `鏡像倉庫源` 則會交由使用者進行互動選擇,屆時會自動清屏 `$ clear`,從而導致你腳本的運行日誌被清除 diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index ade391b..69166fb 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -17,18 +17,18 @@ --md-footer-bg-color--dark: hsla(var(--md-hue), 5%, 12%, 1); --navbar-background: hsla(var(--md-hue), 5%, 19%, 0.33); --hero-background-image: linear-gradient(90deg, rgb(88 88 88) 50%, rgb(88 88 88) 50%); - --component-hover-color: rgba(240, 241, 244, 0.034); + --component-hover-color: rgba(240, 241, 244, 0.05); } [data-md-color-primary=white] { - --md-typeset-a-color: #2080f0; - --md-accent-fg-color: #52a1fc; + --md-typeset-a-color: #1677ff; + --md-accent-fg-color: #0059ff; --md-accent-fg-color--transparent: #52a1fc1a; } [data-md-color-scheme='slate'][data-md-color-primary=black] { --md-typeset-a-color: #5b84f5; - --md-accent-fg-color: #4172f7; + --md-accent-fg-color: #3a75f5; --md-accent-fg-color--transparent: #4172f71a; } @@ -167,6 +167,11 @@ backdrop-filter: blur(8px); } +.md-header__topic { + user-select: none; + -webkit-user-select: none; +} + .md-tabs { background-color: var(--navbar-background) !important; } @@ -239,29 +244,85 @@ border-radius: var(--component-border-radius); } +[data-md-color-scheme='slate'] .md-select__inner { + background-color: rgb(22, 22, 22) !important; +} + .md-select__inner .md-select__list { - padding: var(--component-border-radius) !important; + padding: 6px !important; font-size: .75rem !important; + border-radius: var(--component-border-radius) !important; } .md-select__inner .md-select__list .md-select__item { margin: 1px; - border-radius: var(--component-border-radius); + border-radius: var(--component-border-radius) !important; transition: background-color 0.2s; } -[dir=ltr] .md-select__inner .md-select__list .md-select__item .md-select__link { - border-radius: var(--component-border-radius); +.md-select__inner .md-select__list .md-select__item .md-select__link { padding-left: 12px !important; padding-right: 12px !important; } .md-select__inner .md-select__list .md-select__item:hover { - background-color: rgb(243, 243, 245); + background-color: var(--component-hover-color); } -[data-md-color-scheme='slate'] .md-select__inner .md-select__list .md-select__item:hover { - background-color: rgba(255, 255, 255, 0.07); +.md-header__button>*:first-child, +.md-header__button svg { + height: 24px !important; + width: 24px !important; +} + +@media screen and (min-width: 768px) { + .md-header__button { + border-radius: 6px; + padding: 6px !important; + transition: background-color 0.2s ease-in-out !important; + } + + .md-header__button.md-logo { + margin-left: .4rem !important; + -webkit-user-drag: none; + } + + .md-header__button>*:first-child, + .md-header__button svg { + height: 28px !important; + width: 28px !important; + } + + .md-header__button:hover { + opacity: 1 !important; + background-color: hsla(var(--md-hue), 0%, 0%, .07) !important; + } + + [data-md-color-scheme='slate'] .md-header__button:hover { + background-color: rgba(240, 241, 244, 0.1) !important; + } + + .md-source__repository { + border-radius: 6px !important; + padding: 4px 8px 4px 48px !important; + transition: all 0.2s ease-in-out !important; + } + + .md-source__icon+.md-source__repository { + height: 100%; + } + + .md-source__repository--active:hover { + background-color: hsla(var(--md-hue), 0%, 0%, .07) !important; + } + + .md-source:hover { + opacity: 1 !important; + } + + [data-md-color-scheme='slate'] .md-source__repository--active:hover { + background-color: rgba(240, 241, 244, 0.1) !important; + } } .palette-icon svg { @@ -271,25 +332,23 @@ @media screen and (max-width: 768px) { .palette-icon svg { - width: 22px; - height: 22px; + width: 24px; + height: 24px; } } .md-typeset__table .twemoji svg { fill: var(--md-default-fg-color--light) !important; } + .md-tooltip, .md-tooltip2__inner { border-radius: 5px !important; } -.md-typeset a { - transition: color 0ms; -} - .tabbed-labels a { position: relative; + transition: color 0ms !important; } .tabbed-labels a::before { @@ -322,6 +381,16 @@ margin: 1em 0 !important; } +.md-typeset table, +.md-typeset pre>code, +.md-typeset .grid.cards>ul>li { + border-radius: var(--component-border-radius) !important; +} + +.md-typeset code { + border-radius: 4px !important; +} + /* HERO */ .hero { width: 390px; @@ -664,6 +733,7 @@ /* termynal 插件 */ .termy { padding: 65px 25px 35px !important; + border-radius: var(--component-border-radius) !important; } [data-termynal] { @@ -710,4 +780,4 @@ button[data-terminal-control] { ::view-transition-new(root) { z-index: var(--view-transition-z-index-foreground); -} +} \ No newline at end of file diff --git a/docs/theme/partials/header.html b/docs/theme/partials/header.html index 3c6a668..d51e6f3 100644 --- a/docs/theme/partials/header.html +++ b/docs/theme/partials/header.html @@ -22,7 +22,7 @@ @@ -63,7 +63,7 @@ {% set search = config.plugins["material/search"] | attr("config") %} {% if search.enabled %} {% include "partials/search.html" %} diff --git a/docs/theme/partials/search.html b/docs/theme/partials/search.html index 7bc2447..97beade 100644 --- a/docs/theme/partials/search.html +++ b/docs/theme/partials/search.html @@ -1,4 +1,4 @@ - +
@@ -8,7 +8,7 @@