1. 程式人生 > 其它 >部署docker容器虛擬化平臺

部署docker容器虛擬化平臺

環境: 阿里雲伺服器 CENTOS7.6 64位

[root@localhost ~]# uname -a
Linux localhost 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

1、安裝docker環境依賴

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

2、配置國內docker的yum源

網易163yum源,安裝方法檢視:http://
mirrors.163.com/.help/ 中科大yum源,安裝方法檢視:https://lug.ustc.edu.cn/wiki/mirrors/help 搜狐yum源,安裝方法檢視: http://mirrors.sohu.com/help/ 阿里雲yum源,安裝方法檢視: https://mirrors.aliyun.com/ 清華yum源,安裝方法檢視: https://mirrors.tuna.tsinghua.edu.cn/ 浙大yum源,安裝方法檢視: http://mirrors.zju.edu.cn/ 科大yum源,安裝方法檢視: http://centos.ustc.edu.cn/
方法一:
a.備份yum預設倉庫檔案
[root@localhost ~]# cd /etc/yum.repos.d ---進入倉庫目錄

[root@localhost ~]# mv CentOS-Base.repo CentOS-Base.repo.backup ---備份預設原始檔
b.下載國內倉庫原始檔
[root@localhost ~]# wget -O ./CentOS-Base.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 下載後執行以下兩條命令 
[root@localhost ~]# yum clean all ---清空快取 

[root@localhost ~]# yum
makecache ---生成快取
方法二:
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3、安裝docker-ce:

[root@localhost ~]# yum install docker-ce docker-ce-cli containerd.io -y
docker-ce-cli 是docker命令列工具包,containerd.io 是容器介面相關包
yun info 軟體包的命令,可以檢視一個包的具體作用
[root@localhost
~]# yum info docker-ce docker-ce-cli containerd.io Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Installed Packages Name : containerd.io ... Description : containerd is an industry-standard container runtime with an emphasis on : simplicity, robustness and portability. It is available as a daemon for Linux : and Windows, which can manage the complete container lifecycle of its host : system: image transfer and storage, container execution and supervision, : low-level storage and network attachments, etc. Name : docker-ce .... Description : Docker is a product for you to build, ship and run any application as a : lightweight container. : : Docker containers are both hardware-agnostic and platform-agnostic. This means : they can run anywhere, from your laptop to the largest cloud compute instance and : everything in between - and they don't require you to use a particular : language, framework or packaging system. That makes them great building blocks : for deploying and scaling web apps, databases, and backend services without : depending on a particular stack or provider. Name : docker-ce-cli ... Description : Docker is is a product for you to build, ship and run any application as a : lightweight container. : : Docker containers are both hardware-agnostic and platform-agnostic. This means : they can run anywhere, from your laptop to the largest cloud compute instance and : everything in between - and they don't require you to use a particular : language, framework or packaging system. That makes them great building blocks : for deploying and scaling web apps, databases, and backend services without : depending on a particular stack or provider.

4、啟動並且設定開機自啟

[root@localhost ~]# systemctl start docker && systemctl enable docker

5、顯示 Docker 版本資訊

[root@localhost ~]# docker version
Client: Docker Engine - Community
Version: 20.10.12

Server: Docker Engine - Community
Engine:
Version: 20.10.12
API version: 1.41 (minimum version 1.12)
Go version: go1.16.12

6、檢視 docker 資訊

[root@localhost ~]# docker info #
Client:
...

Server:
...
Server Version: 20.10.12
...
Plugins: 
...
Docker Root Dir: /var/lib/docker ##預設的docker的家目錄
...
Live Restore Enabled: false 

至此,docker環境搭建完成!