- [root@localhost ~]# cat /etc/redhat-release
- CentOS Linux release 7.9.2009 (Core)
- [root@localhost ~]# uname -r
- 3.10.0-1160.71.1.el7.x86_64
-
[root@localhost ~]# yum remove docker docker-common docker-selinux docker-engine
- [root@localhost ~]# curl -fsSL https://get.docker.com -o get-docker.sh
- [root@localhost ~]# bash get-docker.sh
- [root@localhost ~]# yum install yum-utils device-mapper-persistent-data lvm2 -y
- [root@localhost ~]# yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
- [root@localhost ~]# sed -i 's@download.docker.com@mirrors.tuna.tsinghua.edu.cn/docker-ce@g' /etc/yum.repos.d/docker-ce.repo
- [root@localhost ~]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/docker-ce.repo
- [root@localhost ~]# sed -i 's/$basearch/x86_64/g' /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]# yum makecache fast
[root@localhost ~]# yum -y install docker-ce

[root@localhost ~]# rpm -q docker-ce ------------------- 检查安装包docker-ce
docker-ce-20.10.17-3.el7.x86_64
[root@localhost ~]# systemctl start docker ---------- 启动docker服务
[root@localhost ~]# systemctl status docker
安装指定版本
[root@localhost ~]# yum list docker-ce.x86_64 --showduplicates | sort -r
- [root@localhost ~]# cd /etc/yum.repos.d/
- [root@localhost yum.repos.d]# yum install -y https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm
- [root@localhost yum.repos.d]# yum install docker-ce-17.03.3.ce -y
- [root@localhost yum.repos.d]# rpm -q docker-ce
- docker-ce-20.10.17-3.el7.x86_64
- [root@localhost yum.repos.d]# systemctl start docker
- [root@localhost yum.repos.d]# systemctl status docker
[root@localhost ~]# docker --version
Docker version 20.10.17, build 100c701
[root@localhost ~]# docker version
Client: Docker Engine - Community
Version: 20.10.17
[root@localhost ~]# docker run hello-world
[root@localhost ~]# docker run -it ubuntu bash

下载nginx镜像,alpine的镜像httpd的镜像并且给httpd镜像重新打标签
[root@localhost ~]# vi /etc/docker/daemon.json

[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker info
[root@localhost ~]# vi /etc/sysctl.conf
-
[root@localhost ~]# docker pull nginx ----下载nginx镜像(需要等待一段时间)

[root@localhost ~]# docker pull alpine

[root@localhost ~]# docker pull httpd

[root@localhost ~]# docker images | grep httpd
httpd latest f2a976f932ec 2 weeks ago 145MB
[root@localhost ~]# docker tag httpd test/httpd:v1
[root@localhost ~]# docker images | grep httpd
httpd latest f2a976f932ec 2 weeks ago 145MB
test/httpd v1 f2a976f932ec 2 weeks ago 145MB