Skip to content

Docker Installation & Registry Mirror Switcher#

One-Click Command#

bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/DockerInstallation.sh) --en
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) --en

Real-time sync, no delay. Recommended for use in Chinese mainland network environments.

bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) --en

1-hour sync delay.

bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/DockerInstallation.sh) --en
bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) --en

Not recommended in Chinese mainland network environments.

Integrates installation of Docker Engine and Docker Compose, supports selecting or switching software repositories (Docker repositories) and registry mirrors, installing specific versions, reinstalling, and supports ARM architecture.

The script refers to the official documentation and uses the system package manager for installation. There are no compatibility or security issues. The available versions are determined by the Docker CE repository.

bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --only-registry
bash <(curl -sSL https://raw.githubusercontent.com/SuperManito/LinuxMirrors/main/DockerInstallation.sh) --en --only-registry
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) --en --only-registry

Real-time sync, no delay. Recommended for use in Chinese mainland network environments.

bash <(curl -sSL https://raw.gitcode.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) --en --only-registry

1-hour sync delay.

bash <(curl -sSL https://cdn.jsdelivr.net/gh/SuperManito/LinuxMirrors@main/DockerInstallation.sh) --en --only-registry
bash <(curl -sSL https://edgeone.linuxmirrors.cn/docker.sh) --en --only-registry

Not recommended in Chinese mainland network environments.

  • Completely replace the official installation script


    It is logically consistent with get.docker.com and incorporates the repositories and features of this project.

  • Supports domestic derivative operating systems


    Compatible with a number of derivative operating systems not supported by the official installation script.

  • Powerful and unparalleled


    One of the most practical open source operation and maintenance scripts on the entire network, with excellent performance

  • Exquisite interactive design


    An interactive command line interface that is easy to understand and use, way ahead of the competition

✨ After years of technical accumulation and production environment testing, it has been widely praised by the community and deeply loved by developers. It is used by major companies.


Docker Compose does not require a separate installation

Starting from V2, Docker Compose is part of the Docker CLI. The script integrates the installation of this plugin by default. Please use the docker compose command instead of docker-compose.

About Software Sources

  • Docker CE Software Repository


    Docker CE stands for Docker Community Edition, which is another name for Docker Engine. This repository is used to download and install Docker-related packages.

  • Docker Registry Mirror


    Used to control the default source repository for pulling images, also known as a registry accelerator. The default is the official container registry Docker Hub.

Due to some force majeure, Docker Hub is currently inaccessible in the Chinese mainland network environment, so the image cannot be pulled normally. It is recommended to use the image warehouse source available in Chinese mainland mentioned below.

Note: The specified Web protocol in the script is only for controlling the Docker CE software source. Docker Registry always uses the HTTPS protocol.

Built-in Registry Mirrors

Available in Chinese mainland

Site Name Address Description
1ms Mirror docker.1ms.run Enterprise mirror, CDN smart distribution, extremely fast, supports paid customization, recommended
Docker Proxy dockerproxy.net Created by ghproxy, highly available but slow, supports paid enterprise acceleration
DaoCloud docker.m.daocloud.io Well-known enterprise mirror, highly available and fast, now whitelist only
1Panel Mirror docker.1panel.live Enterprise product self-use mirror

This open source project is not suitable for collecting personal self-built registry accelerators. If needed, you can use command options to specify your own.

Others

Site Name Address Site Name Address
Alibaba Cloud (Hangzhou) registry.cn-hangzhou.aliyuncs.com Alibaba Cloud (Japan - Tokyo) registry.ap-northeast-1.aliyuncs.com
Alibaba Cloud (Shanghai) registry.cn-shanghai.aliyuncs.com Alibaba Cloud (Singapore) registry.ap-southeast-1.aliyuncs.com
Alibaba Cloud (Qingdao) registry.cn-qingdao.aliyuncs.com Alibaba Cloud (Malaysia - Kuala Lumpur) registry.ap-southeast-3.aliyuncs.com
Alibaba Cloud (Beijing) registry.cn-beijing.aliyuncs.com Alibaba Cloud (Indonesia - Jakarta) registry.ap-southeast-5.aliyuncs.com
Alibaba Cloud (Zhangjiakou) registry.cn-zhangjiakou.aliyuncs.com Alibaba Cloud (Germany - Frankfurt) registry.eu-central-1.aliyuncs.com
Alibaba Cloud (Hohhot) registry.cn-huhehaote.aliyuncs.com Alibaba Cloud (UK - London) registry.eu-west-1.aliyuncs.com
Alibaba Cloud (Ulanqab) registry.cn-wulanchabu.aliyuncs.com Alibaba Cloud (US West - Silicon Valley) registry.us-west-1.aliyuncs.com
Alibaba Cloud (Shenzhen) registry.cn-shenzhen.aliyuncs.com Alibaba Cloud (US East - Virginia) registry.us-east-1.aliyuncs.com
Alibaba Cloud (Heyuan) registry.cn-heyuan.aliyuncs.com Alibaba Cloud (UAE - Dubai) registry.me-east-1.aliyuncs.com
Alibaba Cloud (Guangzhou) registry.cn-guangzhou.aliyuncs.com Google Cloud (North America) gcr.io
Alibaba Cloud (Chengdu) registry.cn-chengdu.aliyuncs.com Google Cloud (Asia) asia.gcr.io
Alibaba Cloud (Hong Kong) registry.cn-hongkong.aliyuncs.com Google Cloud (Europe) eu.gcr.io
Tencent Cloud mirror.ccs.tencentyun.com Docker Hub registry.hub.docker.com

Note: Registry mirrors from domestic cloud computing companies are only for their own business. Instances in Chinese mainland may still not be able to access Docker Hub.

Command Options (Advanced Usage)#

bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --help
Command options(name/meaning/value):

--source Specify Docker CE mirror address (domain or IP) address
--source-registry Specify Docker Registry mirror address (domain or IP) address
--branch Specify Docker CE mirror repository (path) repo name
--branch-version Specify Docker CE mirror repository version version
--designated-version Specify Docker Engine installation version version
--codename Specify Debian-based OS codename codename
--protocol Specify Web protocol for Docker CE mirror http or https
--use-intranet-source Prefer intranet Docker CE mirror 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
--lang Specify the language of the script output language
--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
--help Show help menu none
Name Meaning Value
--source Specify Docker CE mirror address (domain or IP) address
--source-registry Specify Docker Registry mirror address (domain or IP) address
--branch Specify Docker CE mirror repository (path) repo name (see docs below)
--branch-version Specify Docker CE mirror 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 mirror http or https
--use-intranet-source Prefer intranet Docker CE mirror 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
--lang Specify the language of the script output language id (see docs below)
--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
--help Show help menu none

Full source format: < Web protocol>://<source address (domain or IP)>/<repository path>

  • Specify Registry Mirror Address#

    bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --source-registry registry.example.com
    
  • Only Switch Registry Mirror#

    Only switches the registry accelerator. If Docker is not installed, an error will be reported and exit.

    bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --only-registry
    
    • Install the jq package

      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.

      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 <example.registry.com> with the registry address. See the address column in the "Built-in Registry Mirrors" table above.

      SOURCE_REGISTRY='"https://<example.registry.com>"'
      
      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

      [ -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

      systemctl daemon-reload
      [[ $(systemctl is-active docker) == "active" ]] && systemctl restart docker || systemctl enable --now docker
      
  • Specify Docker CE Source Address#

    bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --source mirror.example.com/docker-ce
    

    Note: The address path must include the Docker CE mirror 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 <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --branch centos
    

    Repository names are fixed: centos, debian, fedora, raspbian, rhel, sles, static, ubuntu
    See official installation docs and Docker CE official repo for details.

    Can also specify the repository version number.
    bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en \
      --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 <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --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.

    How to view available versions
    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

    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).

  • I18n (Internationalization)#

    The script provides multi-language support. Currently, there are three built-in display languages: 简体中文繁體中文English. The default is 简体中文.

    • Specify Language#

      bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --lang xxx
      
      Type Value
      简体中文 zh-hans zh-cn zh
      繁體中文 zh-hant zh-tw zh-hk
      English en en-us

      It can also be used directly as a command option

      bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --zh-hant
      

      --en --en-us --zh --zh-cn --zh-hans --zh-hant

    • Select through interaction#

      bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --lang auto
      
  • Unattended (Automation)#

    To perform installation without interaction, use at least the following options. Recommended for experienced users.

    Example Command
    bash <(curl -sSL https://linuxmirrors.cn/docker.sh) --en \
      --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 <(curl -sSL https://linuxmirrors.cn/docker.sh) --en --pure-mode
    

    Scrolling command logs may have unpredictable display issues, but no problems have been found so far.

FAQ#

  • About Service Startup Errors#

    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:

    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

    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

Best Practices#

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.

  • # !/bin/bash
    function install_docker() {
        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 script_lang="zh-hans"         # script display language: zh-hans / zh-hant / en / auto
        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"                        # 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
            if [ -s "/sys/class/dmi/id/sys_vendor" ]; then
                local sys_vendor="$(cat /sys/class/dmi/id/sys_vendor)"
                if [[ "${sys_vendor}" == *"Alibaba"* ]]; then
                    source_intranet_address="mirrors.cloud.aliyuncs.com/docker-ce"
                elif [[ "${sys_vendor}" == *"Huawei"* ]]; then
                    source_intranet_address="mirrors.myhuaweicloud.com/docker-ce"
                elif [[ "${sys_vendor}" == *"Tencent"* ]]; then
                    source_intranet_address="mirrors.tencentyun.com/docker-ce"
                elif [[ "${sys_vendor}" == *"Inspur"* ]]; then
                    source_intranet_address="mirrors.ivolces.com/docker-ce"
                fi
            else
                cat /etc/motd | grep "Alibaba Cloud " -q
                if [ $? -eq 0 ]; then
                    source_intranet_address="mirrors.cloud.aliyuncs.com/docker-ce"
                fi
            fi
            # check connectivity
            if [ -n "${source_intranet_address}" ]; then
                if ping -c1 -W1 "${source_intranet_address%%/*}" >/dev/null 2>&1; then
                    source_docker_ce_address="${source_intranet_address}"
                    source_docker_ce_protocol="http"
                fi
            fi
            # registry mirror (best choice for Chinese mainland)
            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
    
        # 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}" \
            --close-firewall "${close_firewall}" \
            --install-latest true \
            --ignore-backup-tips \
            --lang "${script_lang}" \
            --pure-mode
    }
    
    install_docker
    
  • Simple method#

    # !/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 \
            --lang auto
    
        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
    

    Note: If you don't specify Docker CE and Docker Registry mirrors, 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.