Kubernetes系列之docker安装

安装docker的方法众多,这里记录下自己习惯使用的方式。
主要参考阿里镜像站。以centos系统为例,步骤如下:

1、安装必要的系统工具
# yum install -y yum-utils device-mapper-persistent-data lvm2
...
Dependency Updated:
  device-mapper.x86_64 7:1.02.170-6.el7_9.5              device-mapper-event.x86_64 7:1.02.170-6.el7_9.5  
  device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5   device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5   
  lvm2-libs.x86_64 7:2.02.187-6.el7_9.5                  lvm2-python-libs.x86_64 7:2.02.187-6.el7_9.5     

Complete!

2、添加yum源码
# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

3、查看安装版本
# yum list docker-ce docker-ce-cli containerd.io --showduplicates |sort -r
 * updates: mirrors.bfsu.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
Installed Packages
 * extras: mirrors.bfsu.edu.cn
...
docker-ce.x86_64              3:19.03.8-3.el7                  docker-ce-stable 
...
docker-ce-cli.x86_64          1:19.03.8-3.el7                  docker-ce-stable 
...
containerd.io.x86_64          1.4.6-3.1.el7                    docker-ce-stable 
...
 * base: mirrors.ustc.edu.cn
Available Packages

4、安装(docker-ce-19.03.8、docker-ce-cli-19.03.8、containerd.io-1.4.6)
# yum install -y docker-ce-19.03.8 docker-ce-cli-19.03.8 containerd.io-1.4.6
...
Downloading packages:
(1/3): docker-ce-19.03.8-3.el7.x86_64.rpm                                          |  25 MB  00:00:03     
(2/3): docker-ce-cli-19.03.8-3.el7.x86_64.rpm                                      |  40 MB  00:00:04     
(3/3): containerd.io-1.4.6-3.1.el7.x86_64.rpm                                      |  34 MB  00:00:09     
----------------------------------------------------------------------------------------------------------
Total                                                                     9.8 MB/s |  98 MB  00:00:09     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:docker-ce-cli-19.03.8-3.el7.x86_64                                                   1/3 
  Installing : containerd.io-1.4.6-3.1.el7.x86_64                                                     2/3 
  Installing : 3:docker-ce-19.03.8-3.el7.x86_64                                                       3/3 
  Verifying  : containerd.io-1.4.6-3.1.el7.x86_64                                                     1/3 
  Verifying  : 1:docker-ce-cli-19.03.8-3.el7.x86_64                                                   2/3 
  Verifying  : 3:docker-ce-19.03.8-3.el7.x86_64                                                       3/3 

Installed:
  containerd.io.x86_64 0:1.4.6-3.1.el7                  docker-ce.x86_64 3:19.03.8-3.el7                 
  docker-ce-cli.x86_64 1:19.03.8-3.el7                 

Complete!

5、设置docker为systemd单元并运行
# mkdir -p /etc/systemd/system/docker.service.d
# systemctl daemon-reload
# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
# systemctl start docker

6、简单的使用
# docker search busybox
NAME                      DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
busybox                   Busybox base image.                             2355                [OK]                
progrium/busybox                                                          70                                      [OK]
radial/busyboxplus        Full-chain, Internet enabled, busybox made f…   43                                      [OK]
...

# docker pull busybox
sing default tag: latest
latest: Pulling from library/busybox
Digest: sha256:f7ca5a32c10d51aeda3b4d01c61c6061f497893d7f6628b92f822f7117182a57
Status: Image is up to date for busybox:latest
docker.io/library/busybox:latest

# docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
busybox                              latest              16ea53ea7c65        2 weeks ago         1.24MB

你可能感兴趣的:(Kubernetes系列之docker安装)