1.1 openEuler使用YUM安装
[root@node1 ~]# yum install docker -y [root@node1 ~]# docker version Client: Version: 18.09.0 EulerVersion: 18.09.0.332 API version: 1.39 Go version: go1.17.3 Git commit: 9942888 Built: Wed Dec 27 10:05:53 2023 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 18.09.0 EulerVersion: 18.09.0.332 API version: 1.39 (minimum version 1.12) Go version: go1.17.3 Git commit: 9942888 Built: Wed Dec 27 10:05:15 2023 OS/Arch: linux/amd64 Experimental: false
1.2 通用二进制方式安装(适合所有版本)
二进制包下载地址: https://download.docker.com/linux/static/stable/x86_64/
[root@node2 ~]# wget -c https://download.docker.com/linux/static/stable/x86_64/docker-25.0.3.tgz [root@node2 ~]# tar xzf docker-25.0.3.tgz -C /usr/local/ #解压 [root@node2 ~]# vim /usr/lib/systemd/system/docker.service #配置服务脚本 [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify EnvironmentFile=-/etc/sysconfig/docker EnvironmentFile=-/etc/sysconfig/docker-storage EnvironmentFile=-/etc/sysconfig/docker-network Environment=GOTRACEBACK=crash ExecStart=/usr/bin/dockerd $OPTIONS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ $INSECURE_REGISTRY ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process [Install] WantedBy=multi-user.target [root@node2 ~]# cp /usr/local/docker/* /usr/bin/ [root@node2 ~]# systemctl start docker.service [root@node2 ~]# docker version Client: Version: 25.0.3 API version: 1.44 Go version: go1.21.6 Git commit: 4debf41 Built: Fri Feb 23 02:37:27 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 25.0.3 API version: 1.44 (minimum version 1.24) Go version: go1.21.6 Git commit: f417435 Built: Fri Feb 23 02:38:33 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.7.13 GitCommit: 7c3aca7a610df76212171d200ca3811ff6096eb8 runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0
注意:该方式没有命令补全
1.3 YUM仓库方式安装(本人推荐)
[root@node2 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 #安装依赖 [root@node2 ~]# wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.huaweicloud.com/docker-ce/linux/centos/docker-ce.repo [root@node2 ~]# sed -i 's+download.docker.com+mirrors.huaweicloud.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo #替换仓库源 [root@node2 ~]# sed -i 's/$releasever/8Server/g' /etc/yum.repos.d/docker-ce.repo #CentOS7只要把8Server换成7Server [root@node2 ~]# yum install docker-ce -y [root@node2 ~]# docker version Client: Docker Engine - Community Version: 20.10.21 API version: 1.41 Go version: go1.18.7 Git commit: baeda1f Built: Tue Oct 25 18:02:19 2022 OS/Arch: linux/amd64 Context: default
1.4 镜像加速器配置
mkdir -p /etc/docker tee /etc/docker/daemon.json << EOF { "registry-mirrors": ["https://lfhqfxbn.mirror.aliyuncs.com"] } EOF systemctl daemon-reload systemctl restart docker
注意:每个人的镜像加速不一样,当然用我的也可以,最好用自己的,在自己阿里云的镜像服务里找。