Docker初体验Note02 - 安装配置

1 docker安装与配置

1.1 版本声明

表1:使用环境及软件版本说明
nameversion
OSCentOS7.7.1908
coreLinux3.10.0-1062.el7.x86_64
containerdocker20.10.2

 

1.2 查看环境

// 查看Linux发行商名称和版本
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
...

// 查看发行商详细版本
[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.7.1908 (Core)

// 查看Linux内核版本
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

 

1.3 安装docker

// 1.卸载旧版本docker
yum remove docker docker-client docker-client-latest docker-common \
    docker-latest docker-latest-logrotate docker-logrotate docker-engine
// 2.下载依赖包
yum install -y yum-utils
// 3.设置镜像仓库为阿里云
yum-config-manager --add-repo \
     http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
// 4.更新yum软件包缓存
yum makecache fast
// 5.安装docker引擎
yum install docker-ce docker-ce-cli containerd.io
图1:docker安装包及依赖说明
* 图示已去水印,供下载使用

 

1.4 docker安装测试

// 启动docker服务
systemctl start docker

// 查看docker版本号, 检验是否安装成功
[root@localhost ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.2
 API version:       1.41
...
Server: Docker Engine - Community
 Engine:
  Version:          20.10.2
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
...

// 运行hello-world镜像
[root@localhost ~]# docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
...

 

2 docker加速配置

使用阿里云容器镜像服务的镜像加速器。

图2:阿里云镜像加速器
* 图示已去水印,供下载使用
// 配置阿里云镜像加速
cp /lib/systemd/system/docker.service /etc/systemd/system/docker.service
chmod 777 /etc/systemd/system/docker.service
vim /etc/systemd/system/docker.service

// 将docker.service文件中的
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
// 替换为
ExecStart=/usr/bin/dockerd --registry-mirror=https://    .mirror.aliyuncs.com

// 重启docker服务
systemctl daemon-reload
systemctl restart docker
[root@localhost ~]# docker info
...
 Registry Mirrors:
  https://    .mirror.aliyuncs.com/

 

3 参考文献

[1][澳]詹姆斯•特恩布尔(James Turnbull).第一本Docker书[M].人民邮电出版社,2014.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值