公司门户网站怎么做,网络公司取名字参考大全,网站空间到期,建站源码程序作者主页#xff1a; 正函数的个人主页 文章收录专栏#xff1a; Docker 欢迎大家点赞 #x1f44d; 收藏 ⭐ 加关注哦#xff01; 安装 Docker
Docker 分为 stable test 和 nightly 三个更新频道。
官方网站上有各种环境下的 安装指南#xff0c;这里主要介绍 Docker 在… 作者主页 正函数的个人主页 文章收录专栏 Docker 欢迎大家点赞 收藏 ⭐ 加关注哦 安装 Docker
Docker 分为 stable test 和 nightly 三个更新频道。
官方网站上有各种环境下的 安装指南这里主要介绍 Docker 在 Linux 、Windows 10 和 macOS 上的安装。 Ubuntu
Ubuntu 安装 Docker 警告切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker. 准备工作 系统要求
Docker 支持以下版本的 Ubuntu 操作系统
Ubuntu Hirsute 21.04Ubuntu Groovy 20.10Ubuntu Focal 20.04 (LTS)Ubuntu Bionic 18.04 (LTS)
Docker 可以安装在 64 位的 x86 平台或 ARM 平台上。Ubuntu 发行版中LTSLong-Term-Support长期支持版本会获得 5 年的升级维护支持这样的版本会更稳定因此在生产环境中推荐使用 LTS 版本。
卸载旧版本
旧版本的 Docker 称为 docker 或者 docker-engine使用以下命令卸载旧版本
$ sudo apt-get remove docker \docker-engine \docker.io使用 APT 安装 由于 apt 源使用 HTTPS 以确保软件下载过程中不被篡改。因此我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。
$ sudo apt-get update$ sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg \lsb-release鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看。
为了确认所下载软件包的合法性需要添加软件源的 GPG 密钥。
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg# 官方源
# $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg然后我们需要向 sources.list 中添加 Docker 软件源
$ echo \deb [archamd64 signed-by/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \$(lsb_release -cs) stable | sudo tee /etc/apt/sources.list.d/docker.list /dev/null# 官方源
# $ echo \
# deb [archamd64 signed-by/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
# $(lsb_release -cs) stable | sudo tee /etc/apt/sources.list.d/docker.list /dev/null以上命令会添加稳定版本的 Docker APT 镜像源如果需要测试版本的 Docker 请将 stable 改为 test。 安装 Docker
更新 apt 软件包缓存并安装 docker-ce
$ sudo apt-get update$ sudo apt-get install docker-ce docker-ce-cli containerd.io使用脚本自动安装 在测试或开发环境中 Docker 官方为了简化安装流程提供了一套便捷的安装脚本Ubuntu 系统上可以使用这套脚本安装另外可以通过 --mirror 选项使用国内源进行安装 若你想安装测试版的 Docker, 请从 test.docker.com 获取脚本 # $ curl -fsSL test.docker.com -o get-docker.sh
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
# $ sudo sh get-docker.sh --mirror AzureChinaCloud执行这个命令后脚本就会自动的将一切准备工作做好并且把 Docker 的稳定(stable)版本安装在系统中。
启动 Docker $ sudo systemctl enable docker
$ sudo systemctl start docker建立 docker 用户组 默认情况下docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑一般 Linux 系统上不会直接使用 root 用户。因此更好地做法是将需要使用 docker 的用户加入 docker 用户组。
建立 docker 组
$ sudo groupadd docker将当前用户加入 docker 组
$ sudo usermod -aG docker $USER退出当前终端并重新登录进行如下测试。
测试 Docker 是否安装正确 $ docker run --rm hello-worldUnable to find image hello-world:latest locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the hello-world image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/若能正常输出以上信息则说明安装成功。
镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。
参考文档
Docker 官方 Ubuntu 安装文档 Debian
Debian 安装 Docker 警告切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker. 准备工作
系统要求
Docker 支持以下版本的 Debian 操作系统
Debian Bullseye 11Debian Buster 10
卸载旧版本
旧版本的 Docker 称为 docker 或者 docker-engine使用以下命令卸载旧版本
$ sudo apt-get remove docker \docker-engine \docker.io使用 APT 安装
由于 apt 源使用 HTTPS 以确保软件下载过程中不被篡改。因此我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。
$ sudo apt-get update$ sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg \lsb-release鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看。
为了确认所下载软件包的合法性需要添加软件源的 GPG 密钥。
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg# 官方源
# $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg然后我们需要向 sources.list 中添加 Docker 软件源 在一些基于 Debian 的 Linux 发行版中 $(lsb_release -cs) 可能不会返回 Debian 的版本代号例如 Kail Linux、 BunsenLabs Linux。在这些发行版中我们需要将下面命令中的 $(lsb_release -cs) 替换为 https://mirrors.aliyun.com/docker-ce/linux/debian/dists/ 中支持的 Debian 版本代号例如 buster。 $ echo \deb [archamd64 signed-by/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/debian \$(lsb_release -cs) stable | sudo tee /etc/apt/sources.list.d/docker.list /dev/null# 官方源
# $ echo \
# deb [archamd64 signed-by/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
# $(lsb_release -cs) stable | sudo tee /etc/apt/sources.list.d/docker.list /dev/null 以上命令会添加稳定版本的 Docker APT 源如果需要测试版本的 Docker 请将 stable 改为 test。 安装 Docker
更新 apt 软件包缓存并安装 docker-ce。
$ sudo apt-get update$ sudo apt-get install docker-ce docker-ce-cli containerd.io使用脚本自动安装
在测试或开发环境中 Docker 官方为了简化安装流程提供了一套便捷的安装脚本Debian 系统上可以使用这套脚本安装另外可以通过 --mirror 选项使用国内源进行安装 若你想安装测试版的 Docker, 请从 test.docker.com 获取脚本 # $ curl -fsSL test.docker.com -o get-docker.sh
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
# $ sudo sh get-docker.sh --mirror AzureChinaCloud执行这个命令后脚本就会自动的将一切准备工作做好并且把 Docker 的稳定(stable)版本安装在系统中。
启动 Docker
$ sudo systemctl enable docker
$ sudo systemctl start docker建立 docker 用户组
默认情况下docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑一般 Linux 系统上不会直接使用 root 用户。因此更好地做法是将需要使用 docker 的用户加入 docker 用户组。
建立 docker 组
$ sudo groupadd docker将当前用户加入 docker 组
$ sudo usermod -aG docker $USER退出当前终端并重新登录进行如下测试。
测试 Docker 是否安装正确
$ docker run --rm hello-worldUnable to find image hello-world:latest locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the hello-world image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/若能正常输出以上信息则说明安装成功。
镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。
参考文档
Docker 官方 Debian 安装文档 Fedora
Fedora 安装 Docker 警告切勿在没有配置 Docker dnf 源的情况下直接使用 dnf 命令安装 Docker. 准备工作
系统要求
Docker 支持以下版本的 Fedora 操作系统
3334
卸载旧版本
旧版本的 Docker 称为 docker 或者 docker-engine使用以下命令卸载旧版本
$ sudo dnf remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-selinux \docker-engine-selinux \docker-engine使用 dnf 安装
执行以下命令安装依赖包
$ sudo dnf -y install dnf-plugins-core鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看。
执行下面的命令添加 dnf 软件源
$ sudo dnf config-manager \--add-repo \https://mirrors.aliyun.com/docker-ce/linux/fedora/docker-ce.repo$ sudo sed -i s/download.docker.com/mirrors.aliyun.com\/docker-ce/g /etc/yum.repos.d/docker-ce.repo# 官方源
# $ sudo dnf config-manager \
# --add-repo \
# https://download.docker.com/linux/fedora/docker-ce.repo如果需要测试版本的 Docker 请使用以下命令
$ sudo dnf config-manager --set-enabled docker-ce-test你也可以禁用测试版本的 Docker
$ sudo dnf config-manager --set-disabled docker-ce-test安装 Docker
更新 dnf 软件源缓存并安装 docker-ce。
$ sudo dnf update
$ sudo dnf install docker-ce docker-ce-cli containerd.io你也可以使用以下命令安装指定版本的 Docker
$ dnf list docker-ce --showduplicates | sort -rdocker-ce.x86_64 18.06.1.ce-3.fc28 docker-ce-stable$ sudo dnf -y install docker-ce-18.06.1.ce使用脚本自动安装
在测试或开发环境中 Docker 官方为了简化安装流程提供了一套便捷的安装脚本Debian 系统上可以使用这套脚本安装另外可以通过 --mirror 选项使用国内源进行安装 若你想安装测试版的 Docker, 请从 test.docker.com 获取脚本 # $ curl -fsSL test.docker.com -o get-docker.sh
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
# $ sudo sh get-docker.sh --mirror AzureChinaCloud执行这个命令后脚本就会自动的将一切准备工作做好并且把 Docker 最新稳定(stable)版本安装在系统中。
启动 Docker
$ sudo systemctl enable docker
$ sudo systemctl start docker建立 docker 用户组
默认情况下docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑一般 Linux 系统上不会直接使用 root 用户。因此更好地做法是将需要使用 docker 的用户加入 docker 用户组。
建立 docker 组
$ sudo groupadd docker将当前用户加入 docker 组
$ sudo usermod -aG docker $USER退出当前终端并重新登录进行如下测试。
测试 Docker 是否安装正确
$ docker run --rm hello-worldUnable to find image hello-world:latest locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the hello-world image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/若能正常输出以上信息则说明安装成功。
镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。
参考文档
Docker 官方 Fedora 安装文档。 CentOS
CentOS 安装 Docker 警告切勿在没有配置 Docker YUM 源的情况下直接使用 yum 命令安装 Docker. 准备工作
系统要求
Docker 支持 64 位版本 CentOS 7/8并且要求内核版本不低于 3.10。 CentOS 7 满足最低内核的要求但由于内核版本比较低部分功能如 overlay2 存储层驱动无法使用并且部分功能可能不太稳定。
卸载旧版本
旧版本的 Docker 称为 docker 或者 docker-engine使用以下命令卸载旧版本
$ sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-selinux \docker-engine-selinux \docker-engine使用 yum 安装
执行以下命令安装依赖包
$ sudo yum install -y yum-utils鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看。
执行下面的命令添加 yum 软件源
$ sudo yum-config-manager \--add-repo \https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo$ sudo sed -i s/download.docker.com/mirrors.aliyun.com\/docker-ce/g /etc/yum.repos.d/docker-ce.repo# 官方源
# $ sudo yum-config-manager \
# --add-repo \
# https://download.docker.com/linux/centos/docker-ce.repo如果需要测试版本的 Docker 请执行以下命令
$ sudo yum-config-manager --enable docker-ce-test安装 Docker
更新 yum 软件源缓存并安装 docker-ce。
$ sudo yum install docker-ce docker-ce-cli containerd.ioCentOS8 额外设置
由于 CentOS8 防火墙使用了 nftables但 Docker 尚未支持 nftables 我们可以使用如下设置使用 iptables
更改 /etc/firewalld/firewalld.conf
# FirewallBackendnftables
FirewallBackendiptables或者执行如下命令
$ firewall-cmd --permanent --zonetrusted --add-interfacedocker0$ firewall-cmd --reload使用脚本自动安装
在测试或开发环境中 Docker 官方为了简化安装流程提供了一套便捷的安装脚本CentOS 系统上可以使用这套脚本安装另外可以通过 --mirror 选项使用国内源进行安装 若你想安装测试版的 Docker, 请从 test.docker.com 获取脚本 # $ curl -fsSL test.docker.com -o get-docker.sh
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
# $ sudo sh get-docker.sh --mirror AzureChinaCloud执行这个命令后脚本就会自动的将一切准备工作做好并且把 Docker 的稳定(stable)版本安装在系统中。
启动 Docker
$ sudo systemctl enable docker
$ sudo systemctl start docker建立 docker 用户组
默认情况下docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑一般 Linux 系统上不会直接使用 root 用户。因此更好地做法是将需要使用 docker 的用户加入 docker 用户组。
建立 docker 组
$ sudo groupadd docker将当前用户加入 docker 组
$ sudo usermod -aG docker $USER退出当前终端并重新登录进行如下测试。
测试 Docker 是否安装正确
$ docker run --rm hello-worldUnable to find image hello-world:latest locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the hello-world image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/若能正常输出以上信息则说明安装成功。
镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。
添加内核参数
如果在 CentOS 使用 Docker 看到下面的这些警告信息
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled请添加内核配置参数以启用这些功能。
$ sudo tee -a /etc/sysctl.conf -EOF
net.bridge.bridge-nf-call-ip6tables 1
net.bridge.bridge-nf-call-iptables 1
EOF然后重新加载 sysctl.conf 即可
$ sudo sysctl -p参考文档
Docker 官方 CentOS 安装文档。https://firewalld.org/2018/07/nftables-backendhttps://github.com/moby/libnetwork/issues/2496 Raspberry Pi
树莓派卡片电脑安装 Docker 警告切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker. 系统要求
Docker 不仅支持 x86_64 架构的计算机同时也支持 ARM 架构的计算机本小节内容以树莓派单片电脑为例讲解 ARM 架构安装 Docker。
Docker 支持以下版本的 Raspberry Pi OS 操作系统
Raspberry Pi OS Buster
注 Raspberry Pi OS 由树莓派的开发与维护机构 树莓派基金会 官方支持并推荐用作树莓派的首选系统其基于 Debian。
使用 APT 安装
由于 apt 源使用 HTTPS 以确保软件下载过程中不被篡改。因此我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。
$ sudo apt-get update$ sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg2 \lsb-release \software-properties-common鉴于国内网络问题强烈建议使用国内源官方源请在注释中查看。
为了确认所下载软件包的合法性需要添加软件源的 GPG 密钥。
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/raspbian/gpg | sudo apt-key add -# 官方源
# $ curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo apt-key add -然后我们需要向 sources.list 中添加 Docker 软件源
$ sudo add-apt-repository \deb [archarmhf] https://mirrors.aliyun.com/docker-ce/linux/raspbian \$(lsb_release -cs) \stable# 官方源
# $ sudo add-apt-repository \
# deb [archarmhf] https://download.docker.com/linux/raspbian \
# $(lsb_release -cs) \
# stable以上命令会添加稳定版本的 Docker APT 源如果需要测试版本的 Docker 请将 stable 改为 test。 安装 Docker
更新 apt 软件包缓存并安装 docker-ce。
$ sudo apt-get update$ sudo apt-get install docker-ce使用脚本自动安装
在测试或开发环境中 Docker 官方为了简化安装流程提供了一套便捷的安装脚本Raspberry Pi OS 系统上可以使用这套脚本安装另外可以通过 --mirror 选项使用国内源进行安装 若你想安装测试版的 Docker, 请从 test.docker.com 获取脚本 # $ curl -fsSL test.docker.com -o get-docker.sh
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun
# $ sudo sh get-docker.sh --mirror AzureChinaCloud执行这个命令后脚本就会自动的将一切准备工作做好并且把 Docker 的稳定(stable)版本安装在系统中。
启动 Docker
$ sudo systemctl enable docker
$ sudo systemctl start docker建立 docker 用户组
默认情况下docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root 用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑一般 Linux 系统上不会直接使用 root 用户。因此更好地做法是将需要使用 docker 的用户加入 docker 用户组。
建立 docker 组
$ sudo groupadd docker将当前用户加入 docker 组
$ sudo usermod -aG docker $USER退出当前终端并重新登录进行如下测试。
测试 Docker 是否安装正确
$ docker run --rm hello-worldUnable to find image hello-world:latest locally
latest: Pulling from library/hello-world
4ee5c797bcd7: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the hello-world image from the Docker Hub.(arm32v7)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/若能正常输出以上信息则说明安装成功。
注意 ARM 平台不能使用 x86 镜像查看 Raspberry Pi OS 可使用镜像请访问 arm32v7 或者 arm64v8。
镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。 Linux 离线安装
离线部署Docker
生产环境中一般都是没有公网资源的本文介绍如何在生产服务器上离线部署Docker
括号内的字母表示该操作需要在哪些服务器上执行
Centos7 离线安装Docker YUM本地文件安装推荐
推荐这种方式是因为在生产环境种一般会选定某个指定的文档软件版本使用。
查询可用的软件版本(A)
#下载清华的镜像源文件
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.reposudo sed -i sdownload.docker.commirrors.tuna.tsinghua.edu.cn/docker-ce /etc/yum.repos.d/docker-ce.repoyum updatesudo yum list docker-ce --showduplicates|sort -rLoading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
docker-ce.x86_64 24.0.4-1.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
....下载到指定文件夹(A)
sudo yum install --downloadonly --downloaddir/tmp/docker24_offline_install/ docker-ce-24.0.4-1.el7 docker-ce-cli-24.0.4-1.el7Dependencies ResolvedPackage Arch Version Repository SizeInstalling:docker-ce x86_64 24.0.4-1.el7 docker 25 M
Installing for dependencies:container-selinux noarch 24.0.4-1.el7 extras 39 kcontainerd.io x86_64 24.0.4-1.el7 docker 23 Mdocker-ce-cli x86_64 24.0.4-1.el7 docker 40 MTransaction SummaryInstall 1 Package (3 Dependent packages)Total download size: 87 M
Installed size: 363 M
Background downloading packages, then exiting:
(1/4): container-selinux-24.0.4-1.el7.noarch.rpm | 39 kB 00:00:00
(2/4): containerd.io-24.0.4-1.el7.x86_64.rpm | 23 MB 00:00:00
(3/4): docker-ce-24.0.4-1.el7.x86_64.rpm | 25 MB 00:00:00
(4/4): docker-ce-cli-24.0.4-1.el7.x86_64.rpm | 40 MB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 118 MB/s | 87 MB 00:00:00
exiting because Download Only specified复制到目标服务器之后进入文件夹安装(C-N)
离线安装时必须使用rpm命令不检查依赖的方式安装
rpm -Uvh *.rpm --nodeps --force锁定软件版本(C-N)
下载锁定版本软件
可参考下文的网络源搭建
sudo yum install yum-plugin-versionlock锁定软件版本
sudo yum versionlock add docker查看锁定列表
sudo yum versionlock listLoaded plugins: fastestmirror, versionlock
3:docker-ce-24.0.4-1.el7.*
versionlock list done锁定后无法再更新
sudo yum install docker-ce
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
Excluding 1 update due to versionlock (use yum versionlock status to show it)
Package 3:docker-ce-24.0.4-1.el7.x86_64 already installed and latest version
Nothing to do解锁指定软件
sudo yum versionlock delete docker-ceLoaded plugins: fastestmirror, versionlock
Deleting versionlock for: 3:docker-ce-24.0.4-1.el7.*
versionlock deleted: 1解锁所有软件
sudo yum versionlock delete allYUM 本地源服务器搭建安装Docker
挂载 ISO 镜像搭建本地 File 源AB
# 删除其他网络源
rm -f /etc/yum.repo.d/*
# 挂载光盘或者iso镜像
mount /dev/cdrom /mnt# 添加本地源
cat /etc/yum.repos.d/local_files.repo EOF
[Local_Files]
nameLocal_Files
baseurlfile:///mnt
enable1
gpgcheck0
gpgkeyfile:///mnt/RPM-GPG-KEY-CentOS-7
EOF# 测试刚才的本地源,安装createrepo软件
yum clean all
yum install createrepo -y根据本地文件搭建BASE网络源B
# 安装apache 服务器
yum install httpd -y
# 挂载光盘
mount /dev/cdrom /mnt
# 新建centos目录
mkdir /var/www/html/base
# 复制光盘内的文件到刚才新建的目录
cp -R /mnt/Packages/* /var/www/html/base/
createrepo /var/www/html/centos/
systemctl enable httpd
systemctl start httpd下载Docker-CE 镜像仓库A
在有网络的服务器上下载Docker-ce镜像
# 下载清华的镜像源文件
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sudo sed -i sdownload.docker.commirrors.tuna.tsinghua.edu.cn/docker-ce /etc/yum.repos.d/docker-ce.repo# 新建 docker-ce目录
mkdir /tmp/docker-ce/
# 把镜像源同步到镜像文件中
reposync -r docker-ce-stable -p /tmp/docker-ce/创建仓库索引B
把下载的 docker-ce 文件夹复制到离线的服务器
# 把docker-ce 文件夹复制到/var/www/html/docker-ce
# 重建索引
createrepo /var/www/html/docker-ce/YUM 客户端设置C…N
rm -f /etc/yum.repo.d/*
cat /etc/yum.repos.d/local_files.repo EOF
[local_base]
namelocal_base
# 改成B服务器地址
baseurlhttp://x.x.x.x/base
enable1
gpgcheck0
proxy_none_
[docker_ce]
namedocker_ce
# 改成B服务器地址
baseurlhttp://x.x.x.x/base
enable1
gpgcheck0
proxy_none_
EOF
Docker 安装C…N
sudo yum makecache fast
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl enable dockermacOS 安装 Docker
系统要求
Docker Desktop for Mac 要求系统最低为 macOS 必须是 10.15 或更高版本 Catalina、Big Sur 或者 Monterey建议升级到最新版本的 macOS。
安装
使用 Homebrew 安装
Homebrew 的 Cask 已经支持 Docker Desktop for Mac因此可以很方便的使用 Homebrew Cask 来进行安装
$ brew install --cask docker手动下载安装
如果需要手动下载请点击以下 链接 下载 Docker Desktop for Mac。 如果你的电脑搭载的是 M1 芯片arm64 架构请点击以下 链接 下载 Docker Desktop for Mac。你可以在 官方文档 查阅已知的问题。 如同 macOS 其它软件一样安装也非常简单双击下载的 .dmg 文件然后将那只叫 Moby 的鲸鱼图标拖拽到 Application 文件夹即可其间需要输入用户密码。
运行
从应用中找到 Docker 图标并点击运行。
运行之后会在右上角菜单栏看到多了一个鲸鱼图标这个图标表明了 Docker 的运行状态。 每次点击鲸鱼图标会弹出操作菜单。 之后你可以在终端通过命令检查安装后的 Docker 版本。
$ docker --version
Docker version 20.10.0, build 7287ab3如果 docker version、docker info 都正常的话可以尝试运行一个 Nginx 服务器
$ docker run -d -p 80:80 --name webserver nginx服务运行后可以访问 http://localhost如果看到了 “Welcome to nginx!”就说明 Docker Desktop for Mac 安装成功了。 要停止 Nginx 服务器并删除执行下面的命令
$ docker stop webserver
$ docker rm webserver镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。
参考链接
官方文档 Windows 10 安装 Docker
系统要求
Docker Desktop for Windows 支持 64 位版本的 Windows 10 Pro且必须开启 Hyper-V若版本为 v1903 及以上则无需开启 Hyper-V或者 64 位版本的 Windows 10 Home v1903 及以上版本。
安装
手动下载安装
点击以下 链接 下载 Docker Desktop for Windows。
下载好之后双击 Docker Desktop Installer.exe 开始安装。
使用 winget 安装
$ winget install Docker.DockerDesktop在 WSL2 运行 Docker
若你的 Windows 版本为 Windows 10 专业版或家庭版 v1903 及以上版本可以使用 WSL2 运行 Docker具体请查看 Docker Desktop WSL 2 backend。
运行
在 Windows 搜索栏输入 Docker 点击 Docker Desktop 开始运行。 Docker 启动之后会在 Windows 任务栏出现鲸鱼图标。 等待片刻当鲸鱼图标静止时说明 Docker 启动成功之后你可以打开 PowerShell 使用 Docker。 推荐使用 Windows Terminal 在终端使用 Docker。 镜像加速
如果在使用过程中发现拉取 Docker 镜像十分缓慢可以配置 Docker 国内镜像加速。
参考链接
官方文档WSL 2 Support is coming to Windows 10 Versions 1903 and 1909 镜像加速器
国内从 Docker Hub 拉取镜像有时会遇到困难此时可以配置镜像加速器。国内很多云服务商都提供了国内加速器服务例如
阿里云加速器(点击管理控制台 - 登录账号(淘宝账号) - 左侧镜像工具 - 镜像加速器 - 复制加速器地址)网易云加速器 https://hub-mirror.c.163.com百度云加速器 https://mirror.baidubce.com
由于镜像服务可能出现宕机建议同时配置多个镜像。各个镜像站测试结果请到 docker-practice/docker-registry-cn-mirror-test 查看。 国内各大云服务商腾讯云、阿里云、百度云均提供了 Docker 镜像加速服务建议根据运行 Docker 的云平台选择对应的镜像加速服务具体请参考本页最后一小节。 本节我们以 网易云 镜像服务 https://hub-mirror.c.163.com 为例进行介绍。
Ubuntu 16.04、Debian 8、CentOS 7
目前主流 Linux 发行版均已使用 systemd 进行服务管理这里介绍如何在使用 systemd 的 Linux 发行版中配置镜像加速器。
请首先执行以下命令查看是否在 docker.service 文件中配置过镜像地址。
$ systemctl cat docker | grep \-\-registry\-mirror如果该命令有输出那么请执行 $ systemctl cat docker 查看 ExecStart 出现的位置修改对应的文件内容去掉 --registry-mirror 参数及其值并按接下来的步骤进行配置。
如果以上命令没有任何输出那么就可以在 /etc/docker/daemon.json 中写入如下内容如果文件不存在请新建该文件
{registry-mirrors: [https://hub-mirror.c.163.com,https://mirror.baidubce.com]
}注意一定要保证该文件符合 json 规范否则 Docker 将不能启动。 之后重新启动服务。
$ sudo systemctl daemon-reload
$ sudo systemctl restart dockerWindows 10
对于使用 Windows 10 的用户在任务栏托盘 Docker 图标内右键菜单选择 Settings打开配置窗口后在左侧导航菜单选择 Docker Engine在右侧像下边一样编辑 json 文件之后点击 Apply Restart 保存后 Docker 就会重启并应用配置的镜像地址了。
{registry-mirrors: [https://hub-mirror.c.163.com,https://mirror.baidubce.com]
}macOS
对于使用 macOS 的用户在任务栏点击 Docker Desktop 应用图标 - Settings...在左侧导航菜单选择 Docker Engine在右侧像下边一样编辑 json 文件。修改完成之后点击 Apply restart 按钮Docker 就会重启并应用配置的镜像地址了。
{registry-mirrors: [https://hub-mirror.c.163.com,https://mirror.baidubce.com]
}检查加速器是否生效
执行 $ docker info如果从结果中看到了如下内容说明配置成功。
Registry Mirrors:https://hub-mirror.c.163.com/k8s.gcr.io 镜像
可以登录 阿里云 容器镜像服务 镜像中心 - 镜像搜索 查找。
例如 k8s.gcr.io/coredns:1.6.7 镜像可以用 registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:1.6.7 代替。
一般情况下有如下对应关系
# $ docker pull k8s.gcr.io/xxx$ docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/xxx不再提供服务的镜像
某些镜像不再提供服务添加无用的镜像加速器会拖慢镜像拉取速度你可以从镜像配置列表中删除它们。
https://dockerhub.azk8s.cn 已转为私有https://reg-mirror.qiniu.comhttps://registry.docker-cn.com
建议 watch页面右上角 镜像测试 这个 GitHub 仓库我们会在此更新各个镜像地址的状态。
云服务商
某些云服务商提供了 仅供内部 访问的镜像服务当您的 Docker 运行在云平台时可以选择它们。 Azure 中国镜像 https://dockerhub.azk8s.cn 腾讯云 https://mirror.ccs.tencentyun.com 开启实验特性
一些 docker 命令或功能仅当 实验特性 开启时才能使用请按照以下方法进行设置。
Docker CLI 的实验特性
从 v20.10 版本开始Docker CLI 所有实验特性的命令均默认开启无需再进行配置或设置系统环境变量。
开启 dockerd 的实验特性
编辑 /etc/docker/daemon.json新增如下条目
{experimental: true
}作者主页 正函数的个人主页 文章收录专栏 Docker 欢迎大家点赞 收藏 ⭐ 加关注哦 如果你认为这篇文章对你有帮助请给正函数点个赞吧如果发现什么问题欢迎评论区留言