1.安装
官方,https://docs.docker.com/engine/install/centos/
1.1yum方式
shell
#安装依赖
yum install device-mapper-persistent-data lvm2 bash-completion -y
#安装具体版本
yum install docker-ce-20.10.15 -y
#或者通过下面脚本进行安装
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh --mirror Aliyun
#安装依赖
yum install device-mapper-persistent-data lvm2 bash-completion -y
#安装具体版本
yum install docker-ce-20.10.15 -y
#或者通过下面脚本进行安装
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh --mirror Aliyun
1.2修改配置文件
shell
#创建docker目录
mkdir /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": [
"native.cgroupdriver=systemd"
],
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"live-restore":true,
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file":"5"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"registry-mirrors" : [
],
"data-root": "/data/docker"
}
EOF
#创建docker目录
mkdir /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": [
"native.cgroupdriver=systemd"
],
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"live-restore":true,
"log-driver": "json-file",
"log-opts": {
"max-size": "100m",
"max-file":"5"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"registry-mirrors" : [
],
"data-root": "/data/docker"
}
EOF
1.3添加用户(可选)
shell
useradd dev
usermod -aG docker dev
newgrp docker
useradd dev
usermod -aG docker dev
newgrp docker
1.4启动
shell
systemctl daemon-reload
systemctl enable --now docker
systemctl daemon-reload
systemctl enable --now docker
1.5 国内加速
yaml
{
"registry-mirrors": [
"https://docker.anyhub.us.kg",
"https://dockerhub.icu",
"https://docker.awsl9527.cn",
"https://gcr.chenby.cn",
"https://k8s.chenby.cn",
"https://docker.chenby.cn"
]
}
{
"registry-mirrors": [
"https://docker.anyhub.us.kg",
"https://dockerhub.icu",
"https://docker.awsl9527.cn",
"https://gcr.chenby.cn",
"https://k8s.chenby.cn",
"https://docker.chenby.cn"
]
}
2. aws
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-docker.html
- To install Docker on Amazon Linux 2 or Amazon Linux 2023
Update the installed packages and package cache on your instance.
$ sudo yum update -y
$ sudo yum update -y
Install the most recent Docker Community Edition package.
For Amazon Linux 2, run the following:
$ sudo amazon-linux-extras install docker
$ sudo amazon-linux-extras install docker
For Amazon Linux 2023, run the following:
$ sudo yum install -y docker
$ sudo yum install -y docker
Start the Docker service.
$ sudo service docker start
$ sudo service docker start
Add the
ec2-user
to thedocker
group so that you can run Docker commands without using sudo.$ sudo usermod -aG docker ec2-user
$ sudo usermod -aG docker ec2-user
3. RockLinux
3.1 卸载
dnf remove podman # 或者 sudo yum remove podman
dnf remove podman # 或者 sudo yum remove podman
3.2 删除残留文件
rm -rf /etc/containers /etc/registries.conf /etc/containers/policy.json /etc/containers/storage.conf ~/.config/containers ~/.local/share/containers
rm -rf /etc/containers /etc/registries.conf /etc/containers/policy.json /etc/containers/storage.conf ~/.config/containers ~/.local/share/containers
3.3 卸载旧版docker
dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
3.4 添加源
vim /etc/yum.repos.d/docker.repo
bash
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirror.nju.edu.cn/docker-ce/linux/rhel/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirror.nju.edu.cn/docker-ce/linux/rhel/gpg
- 清理
bash
yum clean all && yum makecache
yum clean all && yum makecache
3.5 安装
bash
dnf install -y docker-ce docker-ce-cli containerd.io
dnf install -y docker-ce docker-ce-cli containerd.io