CentOS安装Docker(一)

1.在Linux中,可以通过以下命令查看系统版本:

cat /etc/os-release

2.在Linux中,可以通过以下命令查看版本(CentOS 要求内核版本不低于 3.10):

uname -a
Linux VM-8-2-centos 3.10.0-1160.99.1.el7.x86_64

3.如果之前安装过旧版本的Docker,可以使用下面命令卸载:

//换行拼接符号“\”
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine \
                  docker-ce

4.设置本地镜像源

//设置docker镜像源
yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
yum makecache fast

5.安装社区版docker

yum install -y docker-ce
//安装成功
Installed:
  docker-ce.x86_64 3:24.0.7-1.el7                                                                                                                                                                                                                                                                                      

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7      checkpolicy.x86_64 0:2.5-8.el7        container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.6.26-3.1.el7 docker-buildx-plugin.x86_64 0:0.11.2-1.el7 docker-ce-cli.x86_64 1:24.0.7-1.el7        docker-ce-rootless-extras.x86_64 0:24.0.7-1.el7
  docker-compose-plugin.x86_64 0:2.21.0-1.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7                    libcgroup.x86_64 0:0.41-21.el7        libsemanage-python.x86_64 0:2.5-14.el7     policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7                 
  setools-libs.x86_64 0:3.3.8-4.el7           slirp4netns.x86_64 0:0.4.3-4.el7_8   

Complete!

6.查看安装版本

[root@VM-8-2-centos ~]# docker -v
Docker version 24.0.7, build afdd53b

7.关闭防火墙启动docker,启动后在打开

//查看防火墙状态
systemctl status firewalld
Active: active (running) since Mon 2023-12-18 11:17:49 CST; 25s ago  //启动状态
Active: inactive (dead) since Mon 2023-12-18 11:20:25 CST; 2s ago   //关闭状态
//关闭防火墙
systemctl stop firewalld
//启动防火墙
systemctl start firewalld

8.启动docker

systemctl start docker  // 启动docker服务
systemctl stop docker  // 停止docker服务
systemctl restart docker  // 重启docker服务
systemctl status docker  // 查看docker状态

9.docker配置阿里云镜像加速参考文档

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://x2sxlvje.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

10.学习后总结-待续。。。

posted @ 2023-12-18 11:40  o小兵o  阅读(171)  评论(0编辑  收藏  举报